diff --git a/api/migrations/versions/161cadc1af8d_add_dataset_permission_tenant_id.py b/api/migrations/versions/161cadc1af8d_add_dataset_permission_tenant_id.py index fa00004f1abe0b..daa507a7715247 100644 --- a/api/migrations/versions/161cadc1af8d_add_dataset_permission_tenant_id.py +++ b/api/migrations/versions/161cadc1af8d_add_dataset_permission_tenant_id.py @@ -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 ###