ScoDoc/migrations/versions/2b872cb116ca_ajout_taxe_apprentissage_association_.py

80 lines
2.7 KiB
Python

"""ajout taxe apprentissage, association, changement historique
Revision ID: 2b872cb116ca
Revises: d5b3bdd1d622
Create Date: 2022-05-06 18:16:58.727052
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "2b872cb116ca"
down_revision = "d5b3bdd1d622"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"are_taxe_apprentissage",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column("annee", sa.Integer(), nullable=True),
sa.Column("montant", sa.Integer(), nullable=True),
sa.Column("notes", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["entreprise_id"], ["are_entreprises.id"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
)
op.add_column(
"are_entreprises", sa.Column("association", sa.Boolean(), nullable=True)
)
op.add_column("are_logs", sa.Column("entreprise_id", sa.Integer(), nullable=True))
op.add_column("are_logs", sa.Column("object_id", sa.Integer(), nullable=True))
op.alter_column(
"are_logs",
"object",
existing_type=sa.INTEGER(),
type_=sa.Text(),
existing_nullable=True,
)
op.create_index(
op.f("ix_scolar_news_authenticated_user"),
"scolar_news",
["authenticated_user"],
unique=False,
)
op.create_index(op.f("ix_scolar_news_date"), "scolar_news", ["date"], unique=False)
op.create_index(
op.f("ix_scolar_news_object"), "scolar_news", ["object"], unique=False
)
op.create_index(op.f("ix_scolar_news_type"), "scolar_news", ["type"], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_scolar_news_type"), table_name="scolar_news")
op.drop_index(op.f("ix_scolar_news_object"), table_name="scolar_news")
op.drop_index(op.f("ix_scolar_news_date"), table_name="scolar_news")
op.drop_index(op.f("ix_scolar_news_authenticated_user"), table_name="scolar_news")
op.execute(
"alter table are_logs alter column object set data type int using object::integer"
)
op.alter_column(
"are_logs",
"object",
existing_type=sa.Text(),
type_=sa.INTEGER(),
existing_nullable=True,
)
op.drop_column("are_logs", "object_id")
op.drop_column("are_logs", "entreprise_id")
op.drop_column("are_entreprises", "association")
op.drop_table("are_taxe_apprentissage")
# ### end Alembic commands ###