Skip to content

Commit

Permalink
fix: update migration chart_ds_constraint to have seperate batch op (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh authored May 4, 2023
1 parent b7689fb commit f3f5d92
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def upgrade_slc(slc: Slice) -> None:
def upgrade():
bind = op.get_bind()
session = db.Session(bind=bind)

with op.batch_alter_table("slices") as batch_op:
for slc in session.query(Slice).filter(Slice.datasource_type != "table").all():
if slc.datasource_type == "query":
Expand All @@ -97,6 +96,10 @@ def upgrade():
slc.datasource_type,
)

# need commit the updated values for Slice.datasource_type before creating constraint
session.commit()

with op.batch_alter_table("slices") as batch_op:
batch_op.create_check_constraint(
"ck_chart_datasource", "datasource_type in ('table')"
)
Expand Down

0 comments on commit f3f5d92

Please sign in to comment.