forked from ScoDoc/ScoDoc
Etat civil: modifie contraintes dans script migration
This commit is contained in:
parent
a94686957c
commit
a1e6465224
@ -46,7 +46,7 @@ class Identite(db.Model):
|
||||
# données d'état-civil. Si présent remplace les données d'usage dans les documents officiels (bulletins, PV)
|
||||
# cf nomprenom_etat_civil()
|
||||
civilite_etat_civil = db.Column(db.String(1), nullable=False, server_default="X")
|
||||
prenom_etat_civil = db.Column(db.Text(), nullable=True)
|
||||
prenom_etat_civil = db.Column(db.Text(), nullable=False, server_default="")
|
||||
|
||||
date_naissance = db.Column(db.Date)
|
||||
lieu_naissance = db.Column(db.Text())
|
||||
|
@ -17,17 +17,30 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - checked ###
|
||||
op.add_column(
|
||||
"identite",
|
||||
sa.Column("civilite_etat_civil", sa.Text(), nullable=True, server_default="X"),
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("identite", schema=None) as batch_op:
|
||||
batch_op.add_column(
|
||||
sa.Column(
|
||||
"civilite_etat_civil",
|
||||
sa.String(length=1),
|
||||
server_default="X",
|
||||
nullable=False,
|
||||
)
|
||||
op.add_column("identite", sa.Column("prenom_etat_civil", sa.Text(), nullable=True))
|
||||
)
|
||||
batch_op.add_column(
|
||||
sa.Column("prenom_etat_civil", sa.Text(), server_default="", nullable=False)
|
||||
)
|
||||
|
||||
batch_op.create_check_constraint(
|
||||
"identite_civ_etat_civ_check",
|
||||
"civilite_etat_civil IN ('M', 'F', 'X')",
|
||||
)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - checked ###
|
||||
op.drop_column("identite", "prenom_etat_civil")
|
||||
op.drop_column("identite", "civilite_etat_civil")
|
||||
# ### end Alembic commands ###
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("identite", schema=None) as batch_op:
|
||||
batch_op.drop_column("prenom_etat_civil")
|
||||
batch_op.drop_column("civilite_etat_civil")
|
||||
|
Loading…
Reference in New Issue
Block a user