Assiduités : Ajout des migrations

This commit is contained in:
iziram 2023-04-17 15:38:28 +02:00
parent 4691ed8f36
commit 33855cd38d
2 changed files with 166 additions and 0 deletions

View File

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

View File

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