-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migration to include the full "us.lms.org" in Organization.public_id
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
lms/migrations/versions/b512a5cf64ed_public_id_migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Public ID migration | ||
Revision ID: b512a5cf64ed | ||
Revises: 329313b38de1 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
revision = "b512a5cf64ed" | ||
down_revision = "329313b38de1" | ||
|
||
|
||
def upgrade() -> None: | ||
conn = op.get_bind() | ||
conn.execute( | ||
sa.text( | ||
"""UPDATE "organization" set public_id = 'us.lms.org.' || "public_id";""" | ||
) | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
conn = op.get_bind() | ||
conn.execute( | ||
sa.text( | ||
"""UPDATE "organization" set public_id = split_part("public_id", '.', 4);""" | ||
) | ||
) |