ScoDoc-PE/migrations/versions/f3b62d64efa3_creation_tables_relations_entreprises.py

146 lines
8.0 KiB
Python
Raw Normal View History

2021-12-23 19:28:25 +01:00
"""creation tables relations entreprises
2021-12-24 10:43:12 +01:00
Revision ID: f3b62d64efa3
Revises: 91be8a06d423
Create Date: 2021-12-24 10:36:27.150085
2021-12-23 19:28:25 +01:00
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
2021-12-24 10:43:12 +01:00
revision = 'f3b62d64efa3'
2021-12-23 19:28:25 +01:00
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')
)
2021-12-24 10:43:12 +01:00
op.create_table('entreprise_etudiant',
2021-12-23 19:28:25 +01:00
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')
)
2021-12-24 10:43:12 +01:00
2021-12-23 19:28:25 +01:00
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')
)
2021-12-24 10:43:12 +01:00
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),
2021-12-24 10:46:36 +01:00
sa.Column('date_envoi', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
2021-12-24 10:43:12 +01:00
sa.ForeignKeyConstraint(['offre_id'], ['entreprise_offre.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
2021-12-23 19:28:25 +01:00
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))
2021-12-24 10:43:12 +01:00
op.add_column('entreprise_contact', sa.Column('poste', sa.Text(), nullable=True))
op.add_column('entreprise_contact', sa.Column('service', sa.Text(), nullable=True))
2021-12-23 19:28:25 +01:00
op.drop_column('entreprise_contact', 'description')
op.drop_column('entreprise_contact', 'enseignant')
2021-12-24 10:43:12 +01:00
op.drop_column('entreprise_contact', 'date')
op.drop_column('entreprise_contact', 'type_contact')
2021-12-23 19:28:25 +01:00
op.drop_column('entreprise_contact', 'etudid')
2021-12-24 10:43:12 +01:00
op.drop_column('entreprise_contact', 'entreprise_corresp_id')
2021-12-23 19:28:25 +01:00
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')
2021-12-24 10:43:12 +01:00
op.drop_column('entreprises', 'note')
op.drop_column('entreprises', 'contact_origine')
2021-12-23 19:28:25 +01:00
op.drop_column('entreprises', 'plus10salaries')
op.drop_column('entreprises', 'privee')
2021-12-24 10:43:12 +01:00
op.drop_column('entreprises', 'secteur')
2021-12-23 19:28:25 +01:00
op.drop_column('entreprises', 'date_creation')
2021-12-24 10:43:12 +01:00
op.drop_column('entreprises', 'dept_id')
op.drop_column('entreprises', 'localisation')
2021-12-23 19:28:25 +01:00
# ### end Alembic commands ###
2021-12-24 10:43:12 +01:00
2021-12-23 19:28:25 +01:00
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
2021-12-24 10:43:12 +01:00
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))
2021-12-23 19:28:25 +01:00
op.add_column('entreprises', sa.Column('date_creation', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True))
2021-12-24 10:43:12 +01:00
op.add_column('entreprises', sa.Column('secteur', sa.TEXT(), autoincrement=False, nullable=True))
2021-12-23 19:28:25 +01:00
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))
2021-12-24 10:43:12 +01:00
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))
2021-12-23 19:28:25 +01:00
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))
2021-12-24 10:43:12 +01:00
op.add_column('entreprise_contact', sa.Column('etudid', sa.INTEGER(), autoincrement=False, nullable=True))
2021-12-23 19:28:25 +01:00
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))
2021-12-24 10:43:12 +01:00
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))
2021-12-23 19:28:25 +01:00
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'])
2021-12-24 10:43:12 +01:00
op.drop_column('entreprise_contact', 'service')
op.drop_column('entreprise_contact', 'poste')
2021-12-23 19:28:25 +01:00
op.drop_column('entreprise_contact', 'mail')
op.drop_column('entreprise_contact', 'telephone')
op.drop_column('entreprise_contact', 'prenom')
op.drop_column('entreprise_contact', 'nom')
2021-12-24 10:43:12 +01:00
op.drop_table('entreprise_envoi_offre')
2021-12-23 19:28:25 +01:00
op.drop_table('entreprise_offre')
2021-12-24 10:43:12 +01:00
op.drop_table('entreprise_etudiant')
2021-12-23 19:28:25 +01:00
op.drop_table('entreprise_log')
2021-12-24 10:43:12 +01:00
# ### end Alembic commands ###