forked from ScoDoc/DocScoDoc
Fix: suppression de modules avec tags (cascade manquante)
This commit is contained in:
parent
0da60384a1
commit
668210aaef
@ -137,6 +137,12 @@ class NotesTag(db.Model):
|
||||
# Association tag <-> module
|
||||
notes_modules_tags = db.Table(
|
||||
"notes_modules_tags",
|
||||
db.Column("tag_id", db.Integer, db.ForeignKey("notes_tags.id")),
|
||||
db.Column("module_id", db.Integer, db.ForeignKey("notes_modules.id")),
|
||||
db.Column(
|
||||
"tag_id",
|
||||
db.Integer,
|
||||
db.ForeignKey("notes_tags.id", ondelete="CASCADE"),
|
||||
),
|
||||
db.Column(
|
||||
"module_id", db.Integer, db.ForeignKey("notes_modules.id", ondelete="CASCADE")
|
||||
),
|
||||
)
|
||||
|
34
migrations/versions/75cf18659984_cascade_tags_modules.py
Normal file
34
migrations/versions/75cf18659984_cascade_tags_modules.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""cascade tags modules
|
||||
|
||||
Revision ID: 75cf18659984
|
||||
Revises: d74b4e16fb3c
|
||||
Create Date: 2021-10-26 10:17:15.547905
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '75cf18659984'
|
||||
down_revision = 'd74b4e16fb3c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint('notes_modules_tags_tag_id_fkey', 'notes_modules_tags', type_='foreignkey')
|
||||
op.drop_constraint('notes_modules_tags_module_id_fkey', 'notes_modules_tags', type_='foreignkey')
|
||||
op.create_foreign_key(None, 'notes_modules_tags', 'notes_tags', ['tag_id'], ['id'], ondelete='CASCADE')
|
||||
op.create_foreign_key(None, 'notes_modules_tags', 'notes_modules', ['module_id'], ['id'], ondelete='CASCADE')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(None, 'notes_modules_tags', type_='foreignkey')
|
||||
op.drop_constraint(None, 'notes_modules_tags', type_='foreignkey')
|
||||
op.create_foreign_key('notes_modules_tags_module_id_fkey', 'notes_modules_tags', 'notes_modules', ['module_id'], ['id'])
|
||||
op.create_foreign_key('notes_modules_tags_tag_id_fkey', 'notes_modules_tags', 'notes_tags', ['tag_id'], ['id'])
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user