forked from ScoDoc/DocScoDoc
module_type non null
This commit is contained in:
parent
a8e15c839e
commit
41b41c6c55
@ -34,7 +34,7 @@ class Module(db.Model):
|
|||||||
# id de l'element pedagogique Apogee correspondant:
|
# id de l'element pedagogique Apogee correspondant:
|
||||||
code_apogee = db.Column(db.String(APO_CODE_STR_LEN))
|
code_apogee = db.Column(db.String(APO_CODE_STR_LEN))
|
||||||
# Type: ModuleType: DEFAULT, MALUS, RESSOURCE, MODULE_SAE (enum)
|
# Type: ModuleType: DEFAULT, MALUS, RESSOURCE, MODULE_SAE (enum)
|
||||||
module_type = db.Column(db.Integer)
|
module_type = db.Column(db.Integer, nullable=False, default=0, server_default="0")
|
||||||
# Relations:
|
# Relations:
|
||||||
modimpls = db.relationship("ModuleImpl", backref="module", lazy="dynamic")
|
modimpls = db.relationship("ModuleImpl", backref="module", lazy="dynamic")
|
||||||
ues_apc = db.relationship("UniteEns", secondary="module_ue_coef", viewonly=True)
|
ues_apc = db.relationship("UniteEns", secondary="module_ue_coef", viewonly=True)
|
||||||
|
41
migrations/versions/b9aadc10227f_module_type_non_null.py
Normal file
41
migrations/versions/b9aadc10227f_module_type_non_null.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""module_type_non_null
|
||||||
|
|
||||||
|
Revision ID: b9aadc10227f
|
||||||
|
Revises: bd2c1c3d866e
|
||||||
|
Create Date: 2022-02-15 21:47:29.212329
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
from sqlalchemy.orm import sessionmaker # added by ev
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "b9aadc10227f"
|
||||||
|
down_revision = "bd2c1c3d866e"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
Session = sessionmaker()
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# Added by ev: remove duplicates
|
||||||
|
bind = op.get_bind()
|
||||||
|
session = Session(bind=bind)
|
||||||
|
session.execute(
|
||||||
|
"""UPDATE notes_modules SET module_type=0 WHERE module_type IS NULL;"""
|
||||||
|
)
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.alter_column(
|
||||||
|
"notes_modules", "module_type", existing_type=sa.INTEGER(), nullable=False
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.alter_column(
|
||||||
|
"notes_modules", "module_type", existing_type=sa.INTEGER(), nullable=True
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user