From c5fb15fbe80a1425f35fbd4465ff8893c97bb190 Mon Sep 17 00:00:00 2001 From: iziram Date: Mon, 17 Apr 2023 15:38:28 +0200 Subject: [PATCH] =?UTF-8?q?Assiduit=C3=A9s=20:=20Ajout=20des=20migrations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...780b2_assiduites_ajout_user_id_est_just.py | 71 ++++++++++++++ ...75e87f_modèles_assiduites_justificatifs.py | 95 +++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100755 migrations/versions/b555390780b2_assiduites_ajout_user_id_est_just.py create mode 100755 migrations/versions/dbcf2175e87f_modèles_assiduites_justificatifs.py diff --git a/migrations/versions/b555390780b2_assiduites_ajout_user_id_est_just.py b/migrations/versions/b555390780b2_assiduites_ajout_user_id_est_just.py new file mode 100755 index 00000000..2a577fcb --- /dev/null +++ b/migrations/versions/b555390780b2_assiduites_ajout_user_id_est_just.py @@ -0,0 +1,71 @@ +"""assiduites ajout user_id,est_just + +Revision ID: b555390780b2 +Revises: dbcf2175e87f +Create Date: 2023-02-22 18:44:22.643275 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "b555390780b2" +down_revision = "dbcf2175e87f" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column( + "assiduites", + sa.Column( + "user_id", + sa.Integer(), + nullable=True, + ), + ) + op.add_column( + "assiduites", + sa.Column("est_just", sa.Boolean(), server_default="false", nullable=False), + ) + op.create_index( + op.f("ix_assiduites_user_id"), "assiduites", ["user_id"], unique=False + ) + op.create_foreign_key( + "fk_assiduites_user_id", + "assiduites", + "user", + ["user_id"], + ["id"], + ondelete="SET NULL", + ) + op.add_column( + "justificatifs", + sa.Column("user_id", sa.Integer(), nullable=True), + ) + op.create_index( + op.f("ix_justificatifs_user_id"), "justificatifs", ["user_id"], unique=False + ) + op.create_foreign_key( + "fk_justificatifs_user_id", + "justificatifs", + "user", + ["user_id"], + ["id"], + ondelete="SET NULL", + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint("fk_justificatifs_user_id", "justificatifs", type_="foreignkey") + op.drop_index(op.f("ix_justificatifs_user_id"), table_name="justificatifs") + op.drop_column("justificatifs", "user_id") + op.drop_constraint("fk_assiduites_user_id", "assiduites", type_="foreignkey") + op.drop_index(op.f("ix_assiduites_user_id"), table_name="assiduites") + op.drop_column("assiduites", "est_just") + op.drop_column("assiduites", "user_id") + # ### end Alembic commands ### diff --git a/migrations/versions/dbcf2175e87f_modèles_assiduites_justificatifs.py b/migrations/versions/dbcf2175e87f_modèles_assiduites_justificatifs.py new file mode 100755 index 00000000..b74fa27d --- /dev/null +++ b/migrations/versions/dbcf2175e87f_modèles_assiduites_justificatifs.py @@ -0,0 +1,95 @@ +"""modèles assiduites justificatifs + +Revision ID: dbcf2175e87f +Revises: 5c7b208355df +Create Date: 2023-02-01 14:21:06.989190 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "dbcf2175e87f" +down_revision = "6520faf67508" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "justificatifs", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column( + "date_debut", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=False, + ), + sa.Column( + "date_fin", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=False, + ), + sa.Column("etudid", sa.Integer(), nullable=False), + sa.Column("etat", sa.Integer(), nullable=False), + sa.Column( + "entry_date", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=True, + ), + sa.Column("raison", sa.Text(), nullable=True), + sa.Column("fichier", sa.Text(), nullable=True), + sa.ForeignKeyConstraint(["etudid"], ["identite.id"], ondelete="CASCADE"), + sa.PrimaryKeyConstraint("id"), + ) + op.create_index( + op.f("ix_justificatifs_etudid"), "justificatifs", ["etudid"], unique=False + ) + op.create_table( + "assiduites", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column( + "date_debut", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=False, + ), + sa.Column( + "date_fin", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=False, + ), + sa.Column("moduleimpl_id", sa.Integer(), nullable=True), + sa.Column("etudid", sa.Integer(), nullable=False), + sa.Column("etat", sa.Integer(), nullable=False), + sa.Column("desc", sa.Text(), nullable=True), + sa.Column( + "entry_date", + sa.DateTime(timezone=True), + server_default=sa.text("now()"), + nullable=True, + ), + sa.ForeignKeyConstraint(["etudid"], ["identite.id"], ondelete="CASCADE"), + sa.ForeignKeyConstraint( + ["moduleimpl_id"], ["notes_moduleimpl.id"], ondelete="SET NULL" + ), + sa.PrimaryKeyConstraint("id"), + ) + op.create_index( + op.f("ix_assiduites_etudid"), "assiduites", ["etudid"], unique=False + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f("ix_assiduites_etudid"), table_name="assiduites") + op.drop_table("assiduites") + op.drop_index(op.f("ix_justificatifs_etudid"), table_name="justificatifs") + op.drop_table("justificatifs") + # ### end Alembic commands ###