Skip to content

Commit

Permalink
feat: migrate upgrade when tenant_id is null
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouhaoJiang committed Jul 8, 2024
1 parent 07044d6 commit 5cc539a
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ def upgrade():
"""
)

# Step 3: Alter column to NOT NULL
# Step 3: Update the column to set a default value for existing rows
op.execute(
"""
UPDATE dataset_permissions
SET tenant_id = '00000000-0000-0000-0000-000000000000'
WHERE tenant_id IS NULL
"""
)

# Step 4: Alter column to NOT NULL
op.alter_column('dataset_permissions', 'tenant_id', nullable=False)

# ### end Alembic commands ###
Expand Down

0 comments on commit 5cc539a

Please sign in to comment.