mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: add cascades for foreign keys
This commit is contained in:
parent
494620d2d6
commit
0fc6713ec8
7 changed files with 216 additions and 6 deletions
|
|
@ -0,0 +1,47 @@
|
|||
"""Org IDs Cascades
|
||||
|
||||
Revision ID: 83b6d9d6f57a
|
||||
Revises: cb2029aadc2d
|
||||
Create Date: 2024-08-29 19:38:10.022100
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa # noqa: F401
|
||||
import sqlmodel # noqa: F401
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '83b6d9d6f57a'
|
||||
down_revision: Union[str, None] = 'cb2029aadc2d'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('chapter_org_id_fkey', 'chapter', type_='foreignkey')
|
||||
op.drop_constraint('chapteractivity_org_id_fkey', 'chapteractivity', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'chapteractivity', 'organization', ['org_id'], ['id'], ondelete='CASCADE')
|
||||
op.drop_constraint('collectioncourse_org_id_fkey', 'collectioncourse', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'collectioncourse', 'organization', ['org_id'], ['id'], ondelete='CASCADE')
|
||||
op.drop_constraint('coursechapter_org_id_fkey', 'coursechapter', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'coursechapter', 'organization', ['org_id'], ['id'], ondelete='CASCADE')
|
||||
op.drop_constraint('courseupdate_org_id_fkey', 'courseupdate', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'courseupdate', 'organization', ['org_id'], ['id'], ondelete='CASCADE')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'courseupdate', type_='foreignkey')
|
||||
op.create_foreign_key('courseupdate_org_id_fkey', 'courseupdate', 'organization', ['org_id'], ['id'])
|
||||
op.drop_constraint(None, 'coursechapter', type_='foreignkey')
|
||||
op.create_foreign_key('coursechapter_org_id_fkey', 'coursechapter', 'organization', ['org_id'], ['id'])
|
||||
op.drop_constraint(None, 'collectioncourse', type_='foreignkey')
|
||||
op.create_foreign_key('collectioncourse_org_id_fkey', 'collectioncourse', 'organization', ['org_id'], ['id'])
|
||||
op.drop_constraint(None, 'chapteractivity', type_='foreignkey')
|
||||
op.create_foreign_key('chapteractivity_org_id_fkey', 'chapteractivity', 'organization', ['org_id'], ['id'])
|
||||
op.create_foreign_key('chapter_org_id_fkey', 'chapter', 'organization', ['org_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
||||
Loading…
Add table
Add a link
Reference in a new issue