ScoDoc/migrations/versions/d5b3bdd1d622_ajout_colonnes_tables_relations_.py

66 lines
2.3 KiB
Python
Raw Normal View History

"""ajout colonnes tables relations entreprises, sites
Revision ID: d5b3bdd1d622
Revises: e97b2a10f86c
Create Date: 2022-04-25 18:29:50.841280
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "d5b3bdd1d622"
down_revision = "e97b2a10f86c"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"are_sites",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column("nom", sa.Text(), nullable=True),
sa.Column("adresse", sa.Text(), nullable=True),
sa.Column("codepostal", sa.Text(), nullable=True),
sa.Column("ville", sa.Text(), nullable=True),
sa.Column("pays", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(
["entreprise_id"], ["are_entreprises.id"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
)
op.add_column(
"are_correspondants", sa.Column("site_id", sa.Integer(), nullable=True)
)
op.add_column(
"are_correspondants", sa.Column("civilite", sa.String(length=1), nullable=True)
)
op.add_column("are_correspondants", sa.Column("origine", sa.Text(), nullable=True))
op.add_column("are_correspondants", sa.Column("notes", sa.Text(), nullable=True))
op.create_foreign_key(
None, "are_correspondants", "are_sites", ["site_id"], ["id"], ondelete="cascade"
)
op.add_column("are_entreprises", sa.Column("active", sa.Boolean(), nullable=True))
op.add_column(
"are_entreprises", sa.Column("notes_active", sa.Text(), nullable=True)
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("are_entreprises", "notes_active")
op.drop_column("are_entreprises", "active")
op.drop_constraint(
"are_correspondants_site_id_fkey", "are_correspondants", type_="foreignkey"
)
op.drop_column("are_correspondants", "notes")
op.drop_column("are_correspondants", "origine")
op.drop_column("are_correspondants", "civilite")
op.drop_column("are_correspondants", "site_id")
op.drop_table("are_sites")
# ### end Alembic commands ###