budget/alembic/versions/287fe9e6682a_add_relationships.py

110 lines
2.7 KiB
Python

"""Add relationships
Revision ID: 287fe9e6682a
Revises: d3534f493239
Create Date: 2022-12-03 16:43:39.633382+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "287fe9e6682a"
down_revision = "d3534f493239"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
"fk_categorized_id_originals",
"categorized",
schema="transactions",
type_="foreignkey",
)
op.create_foreign_key(
op.f("fk_categorized_id_originals"),
"categorized",
"originals",
["id"],
["id"],
source_schema="transactions",
referent_schema="transactions",
ondelete="CASCADE",
)
op.drop_constraint(
"fk_notes_id_originals", "notes", schema="transactions", type_="foreignkey"
)
op.create_foreign_key(
op.f("fk_notes_id_originals"),
"notes",
"originals",
["id"],
["id"],
source_schema="transactions",
referent_schema="transactions",
ondelete="CASCADE",
)
op.drop_constraint(
"fk_tags_id_originals", "tags", schema="transactions", type_="foreignkey"
)
op.create_foreign_key(
op.f("fk_tags_id_originals"),
"tags",
"originals",
["id"],
["id"],
source_schema="transactions",
referent_schema="transactions",
ondelete="CASCADE",
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
op.f("fk_tags_id_originals"), "tags", schema="transactions", type_="foreignkey"
)
op.create_foreign_key(
"fk_tags_id_originals",
"tags",
"originals",
["id"],
["id"],
source_schema="transactions",
referent_schema="transactions",
)
op.drop_constraint(
op.f("fk_notes_id_originals"),
"notes",
schema="transactions",
type_="foreignkey",
)
op.create_foreign_key(
"fk_notes_id_originals",
"notes",
"originals",
["id"],
["id"],
source_schema="transactions",
referent_schema="transactions",
)
op.drop_constraint(
op.f("fk_categorized_id_originals"),
"categorized",
schema="transactions",
type_="foreignkey",
)
op.create_foreign_key(
"fk_categorized_id_originals",
"categorized",
"originals",
["id"],
["id"],
source_schema="transactions",
referent_schema="transactions",
)
# ### end Alembic commands ###