Skip to content

Commit

Permalink
Migration to include the full "us.lms.org" in Organization.public_id
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospri committed Jun 10, 2024
1 parent 80c9b17 commit a8b2846
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lms/migrations/versions/b512a5cf64ed_public_id_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Public ID migration.
Revision ID: b512a5cf64ed
Revises: 329313b38de1
"""

import os

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

revision = "b512a5cf64ed"
down_revision = "329313b38de1"


def upgrade() -> None:
region = os.environ["REGION_CODE"]
conn = op.get_bind()
conn.execute(
sa.text(
f"""UPDATE "organization" set public_id = '{region}.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);"""
)
)

0 comments on commit a8b2846

Please sign in to comment.