Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions migrations/versions/7bf4eac76958_add_rule_id_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("cre_links", schema=None) as batch_op:
batch_op.drop_constraint("uq_cre_link_pair", type_="unique")
batch_op.create_unique_constraint("uq_pair", ["group", "cre"])

with op.batch_alter_table("cre_node_links", schema=None) as batch_op:
batch_op.drop_constraint("uq_cre_node_link_pair", type_="unique")
batch_op.create_unique_constraint("uq_pair", ["cre", "node"])

# NOTE: the original auto-generated diff also renamed the unique constraints
# on cre_links (uq_cre_link_pair) and cre_node_links (uq_cre_node_link_pair)
# to a shared name "uq_pair". On PostgreSQL a UNIQUE constraint creates a
# schema-global index, so two "uq_pair" indexes on two tables collide
# ("relation uq_pair already exists") and break a from-empty
# `flask db upgrade`. Those renames are removed: the preceding migration
# (0d267ae11945) already creates the table-specific constraints and the
# models keep those names, so we preserve them here.
with op.batch_alter_table("node", schema=None) as batch_op:
batch_op.add_column(sa.Column("section_id", sa.String(), nullable=True))
batch_op.drop_constraint("uq_node", type_="unique")
Expand Down Expand Up @@ -56,12 +56,4 @@ def downgrade():
)
batch_op.drop_column("section_id")

with op.batch_alter_table("cre_node_links", schema=None) as batch_op:
batch_op.drop_constraint("uq_pair", type_="unique")
batch_op.create_unique_constraint("uq_cre_node_link_pair", ["cre", "node"])

with op.batch_alter_table("cre_links", schema=None) as batch_op:
batch_op.drop_constraint("uq_pair", type_="unique")
batch_op.create_unique_constraint("uq_cre_link_pair", ["group", "cre"])

# ### end Alembic commands ###
Loading