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