ScoDoc/migrations/versions/f3b62d64efa3_creation_tables_relations_entreprises.py

146 lines
8.0 KiB
Python

"""creation tables relations entreprises
Revision ID: f3b62d64efa3
Revises: 91be8a06d423
Create Date: 2021-12-24 10:36:27.150085
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'f3b62d64efa3'
down_revision = '91be8a06d423'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('entreprise_log',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('date', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('authenticated_user', sa.Text(), nullable=True),
sa.Column('object', sa.Integer(), nullable=True),
sa.Column('text', sa.Text(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('entreprise_etudiant',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('entreprise_id', sa.Integer(), nullable=True),
sa.Column('etudid', sa.Integer(), nullable=True),
sa.Column('type_offre', sa.Text(), nullable=True),
sa.Column('date_debut', sa.Date(), nullable=True),
sa.Column('date_fin', sa.Date(), nullable=True),
sa.Column('formation_text', sa.Text(), nullable=True),
sa.Column('formation_scodoc', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['entreprise_id'], ['entreprises.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('entreprise_offre',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('entreprise_id', sa.Integer(), nullable=True),
sa.Column('date_ajout', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.Column('intitule', sa.Text(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('type_offre', sa.Text(), nullable=True),
sa.Column('missions', sa.Text(), nullable=True),
sa.Column('duree', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['entreprise_id'], ['entreprises.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('entreprise_envoi_offre',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('offre_id', sa.Integer(), nullable=True),
sa.Column('date_envoi', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
sa.ForeignKeyConstraint(['offre_id'], ['entreprise_offre.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_constraint('entreprise_contact_entreprise_corresp_id_fkey', 'entreprise_contact', type_='foreignkey')
op.drop_table('entreprise_correspondant')
op.add_column('entreprise_contact', sa.Column('nom', sa.Text(), nullable=True))
op.add_column('entreprise_contact', sa.Column('prenom', sa.Text(), nullable=True))
op.add_column('entreprise_contact', sa.Column('telephone', sa.Text(), nullable=True))
op.add_column('entreprise_contact', sa.Column('mail', sa.Text(), nullable=True))
op.add_column('entreprise_contact', sa.Column('poste', sa.Text(), nullable=True))
op.add_column('entreprise_contact', sa.Column('service', sa.Text(), nullable=True))
op.drop_column('entreprise_contact', 'description')
op.drop_column('entreprise_contact', 'enseignant')
op.drop_column('entreprise_contact', 'date')
op.drop_column('entreprise_contact', 'type_contact')
op.drop_column('entreprise_contact', 'etudid')
op.drop_column('entreprise_contact', 'entreprise_corresp_id')
op.add_column('entreprises', sa.Column('siret', sa.Text(), nullable=True))
op.drop_index('ix_entreprises_dept_id', table_name='entreprises')
op.drop_constraint('entreprises_dept_id_fkey', 'entreprises', type_='foreignkey')
op.drop_column('entreprises', 'qualite_relation')
op.drop_column('entreprises', 'note')
op.drop_column('entreprises', 'contact_origine')
op.drop_column('entreprises', 'plus10salaries')
op.drop_column('entreprises', 'privee')
op.drop_column('entreprises', 'secteur')
op.drop_column('entreprises', 'date_creation')
op.drop_column('entreprises', 'dept_id')
op.drop_column('entreprises', 'localisation')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('entreprises', sa.Column('localisation', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('dept_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('date_creation', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('secteur', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('privee', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('plus10salaries', sa.BOOLEAN(), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('contact_origine', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('note', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('entreprises', sa.Column('qualite_relation', sa.INTEGER(), autoincrement=False, nullable=True))
op.create_foreign_key('entreprises_dept_id_fkey', 'entreprises', 'departement', ['dept_id'], ['id'])
op.create_index('ix_entreprises_dept_id', 'entreprises', ['dept_id'], unique=False)
op.drop_column('entreprises', 'siret')
op.add_column('entreprise_contact', sa.Column('entreprise_corresp_id', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('entreprise_contact', sa.Column('etudid', sa.INTEGER(), autoincrement=False, nullable=True))
op.add_column('entreprise_contact', sa.Column('type_contact', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('entreprise_contact', sa.Column('date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True))
op.add_column('entreprise_contact', sa.Column('enseignant', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('entreprise_contact', sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True))
op.create_table('entreprise_correspondant',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('entreprise_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('nom', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('prenom', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('civilite', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('fonction', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('phone1', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('phone2', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('mobile', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('mail1', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('mail2', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('fax', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('note', sa.TEXT(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['entreprise_id'], ['entreprises.id'], name='entreprise_correspondant_entreprise_id_fkey'),
sa.PrimaryKeyConstraint('id', name='entreprise_correspondant_pkey')
)
op.create_foreign_key('entreprise_contact_entreprise_corresp_id_fkey', 'entreprise_contact', 'entreprise_correspondant', ['entreprise_corresp_id'], ['id'])
op.drop_column('entreprise_contact', 'service')
op.drop_column('entreprise_contact', 'poste')
op.drop_column('entreprise_contact', 'mail')
op.drop_column('entreprise_contact', 'telephone')
op.drop_column('entreprise_contact', 'prenom')
op.drop_column('entreprise_contact', 'nom')
op.drop_table('entreprise_envoi_offre')
op.drop_table('entreprise_offre')
op.drop_table('entreprise_etudiant')
op.drop_table('entreprise_log')
# ### end Alembic commands ###