forked from ScoDoc/ScoDoc
Missing cascade: Suppression modimpls avec enseignants associés Fix #495
This commit is contained in:
parent
ad00f06663
commit
1ccb387e59
@ -108,9 +108,9 @@ notes_modules_enseignants = db.Table(
|
||||
db.Column(
|
||||
"moduleimpl_id",
|
||||
db.Integer,
|
||||
db.ForeignKey("notes_moduleimpl.id"),
|
||||
db.ForeignKey("notes_moduleimpl.id", ondelete="CASCADE"),
|
||||
),
|
||||
db.Column("ens_id", db.Integer, db.ForeignKey("user.id")),
|
||||
db.Column("ens_id", db.Integer, db.ForeignKey("user.id", ondelete="CASCADE")),
|
||||
# ? db.UniqueConstraint("moduleimpl_id", "ens_id"),
|
||||
)
|
||||
# XXX il manque probablement une relation pour gérer cela
|
||||
|
@ -0,0 +1,74 @@
|
||||
"""Cascades sur notes_modules_enseignants
|
||||
|
||||
Revision ID: 6bc3f51154b4
|
||||
Revises: 814e8e37d082
|
||||
Create Date: 2022-09-21 13:12:47.850227
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "6bc3f51154b4"
|
||||
down_revision = "814e8e37d082"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_constraint(
|
||||
"notes_modules_enseignants_moduleimpl_id_fkey",
|
||||
"notes_modules_enseignants",
|
||||
type_="foreignkey",
|
||||
)
|
||||
op.drop_constraint(
|
||||
"notes_modules_enseignants_ens_id_fkey",
|
||||
"notes_modules_enseignants",
|
||||
type_="foreignkey",
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"notes_modules_enseignants",
|
||||
"user",
|
||||
["ens_id"],
|
||||
["id"],
|
||||
ondelete="CASCADE",
|
||||
)
|
||||
op.create_foreign_key(
|
||||
None,
|
||||
"notes_modules_enseignants",
|
||||
"notes_moduleimpl",
|
||||
["moduleimpl_id"],
|
||||
["id"],
|
||||
ondelete="CASCADE",
|
||||
)
|
||||
op.alter_column("role", "name", existing_type=sa.VARCHAR(length=64), nullable=False)
|
||||
op.drop_constraint("role_name_key", "role", type_="unique")
|
||||
op.create_index(op.f("ix_role_name"), "role", ["name"], unique=True)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f("ix_role_name"), table_name="role")
|
||||
op.create_unique_constraint("role_name_key", "role", ["name"])
|
||||
op.alter_column("role", "name", existing_type=sa.VARCHAR(length=64), nullable=True)
|
||||
op.drop_constraint(None, "notes_modules_enseignants", type_="foreignkey")
|
||||
op.drop_constraint(None, "notes_modules_enseignants", type_="foreignkey")
|
||||
op.create_foreign_key(
|
||||
"notes_modules_enseignants_ens_id_fkey",
|
||||
"notes_modules_enseignants",
|
||||
"user",
|
||||
["ens_id"],
|
||||
["id"],
|
||||
)
|
||||
op.create_foreign_key(
|
||||
"notes_modules_enseignants_moduleimpl_id_fkey",
|
||||
"notes_modules_enseignants",
|
||||
"notes_moduleimpl",
|
||||
["moduleimpl_id"],
|
||||
["id"],
|
||||
)
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user