Skip to content

Commit

Permalink
migration to remove Zulu locale. (#4353)
Browse files Browse the repository at this point in the history
Migration for PR #4349
  • Loading branch information
pbugni authored Dec 6, 2023
1 parent b2a39b3 commit e53c159
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
6 changes: 0 additions & 6 deletions portal/config/eproms/Coding.json
Original file line number Diff line number Diff line change
Expand Up @@ -6114,12 +6114,6 @@
"resourceType": "Coding",
"system": "urn:ietf:bcp:47"
},
{
"code": "zu_ZA",
"display": "Zulu",
"resourceType": "Coding",
"system": "urn:ietf:bcp:47"
},
{
"code": "pt_BR",
"display": "Portuguese (Brazil)",
Expand Down
43 changes: 43 additions & 0 deletions portal/migrations/versions/d1f3ed8d16ef_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""remove Zulu locale
Revision ID: d1f3ed8d16ef
Revises: 80c3b1e96c45
Create Date: 2023-12-05 14:09:10.442328
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'd1f3ed8d16ef'
down_revision = '80c3b1e96c45'


def upgrade():
# switch user's locale to GB english for any user with Zulu
op.execute(
"update users set locale_id = "
"(select codeable_concept_id from codeable_concept_codings where coding_id in "
"(select id from codings where code = 'en_GB')) where locale_id = "
"(select codeable_concept_id from codeable_concept_codings where coding_id in "
"(select id from codings where code = 'zu_ZA'))"
)

# remove the Zulu codeable_concept
op.execute(
"delete from codeable_concept_codings where coding_id in "
"(select id from codings where code = 'zu_ZA')")

# remove Zulu from any orgs
op.execute(
"delete from organization_locales where coding_id = (select id from codings where code = 'zu_ZA')"
)

# remove the Zulu coding
op.execute("delete from codings where code = 'zu_ZA'")


def downgrade():
# no restoration path
pass

0 comments on commit e53c159

Please sign in to comment.