ScoDoc/migrations/versions/7e5b519a27e1_cascade_modimpls.py

44 lines
1.1 KiB
Python
Raw Normal View History

2023-01-12 12:52:32 +01:00
"""cascade_modimpls
Revision ID: 7e5b519a27e1
Revises: 554c13cea377
Create Date: 2023-01-12 08:49:01.744120
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7e5b519a27e1"
down_revision = "554c13cea377"
branch_labels = None
depends_on = None
def upgrade():
#
op.execute("DELETE FROM notes_moduleimpl WHERE module_id is NULL;")
op.alter_column(
"notes_moduleimpl", "module_id", existing_type=sa.INTEGER(), nullable=False
)
op.execute("DELETE FROM notes_moduleimpl WHERE formsemestre_id is NULL;")
op.alter_column(
"notes_moduleimpl",
"formsemestre_id",
existing_type=sa.INTEGER(),
nullable=False,
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"notes_moduleimpl", "formsemestre_id", existing_type=sa.INTEGER(), nullable=True
)
op.alter_column(
"notes_moduleimpl", "module_id", existing_type=sa.INTEGER(), nullable=True
)
# ### end Alembic commands ###