1
0
forked from ScoDoc/ScoDoc
ScoDoc-Front/migrations/versions/6bc3f51154b4_cascades_sur_notes_modules_enseignants.py

75 lines
2.1 KiB
Python

"""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 ###