1
0
forked from ScoDoc/ScoDoc

update migration version

This commit is contained in:
Arthur ZHU 2021-12-29 11:26:41 +01:00
parent 065bcfe1a0
commit 4d2d2f20fb
2 changed files with 221 additions and 112 deletions

View File

@ -34,14 +34,13 @@ from app.entreprises.models import (
) )
from app.models import Identite from app.models import Identite
from app.auth.models import User from app.auth.models import User
from app.scodoc.sco_find_etud import search_etud_by_name
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc import sco_etud, sco_excel from app.scodoc import sco_etud, sco_excel
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app import db from app import db
from sqlalchemy import text from sqlalchemy import text
from werkzeug.utils import secure_filename, send_from_directory from werkzeug.utils import secure_filename
@bp.route("/", methods=["GET"]) @bp.route("/", methods=["GET"])

View File

@ -10,136 +10,246 @@ import sqlalchemy as sa
from sqlalchemy.dialects import postgresql from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = 'f3b62d64efa3' revision = "f3b62d64efa3"
down_revision = '91be8a06d423' down_revision = "91be8a06d423"
branch_labels = None branch_labels = None
depends_on = None depends_on = None
def upgrade(): def upgrade():
# ### commands auto generated by Alembic - please adjust! ### # ### commands auto generated by Alembic - please adjust! ###
op.create_table('entreprise_log', op.create_table(
sa.Column('id', sa.Integer(), nullable=False), "entreprise_log",
sa.Column('date', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), sa.Column("id", sa.Integer(), nullable=False),
sa.Column('authenticated_user', sa.Text(), nullable=True), sa.Column(
sa.Column('object', sa.Integer(), nullable=True), "date",
sa.Column('text', sa.Text(), nullable=True), sa.DateTime(timezone=True),
sa.PrimaryKeyConstraint('id') 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', op.create_table(
sa.Column('id', sa.Integer(), nullable=False), "entreprise_etudiant",
sa.Column('entreprise_id', sa.Integer(), nullable=True), sa.Column("id", sa.Integer(), nullable=False),
sa.Column('etudid', sa.Integer(), nullable=True), sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column('type_offre', sa.Text(), nullable=True), sa.Column("etudid", sa.Integer(), nullable=True),
sa.Column('date_debut', sa.Date(), nullable=True), sa.Column("type_offre", sa.Text(), nullable=True),
sa.Column('date_fin', sa.Date(), nullable=True), sa.Column("date_debut", sa.Date(), nullable=True),
sa.Column('formation_text', sa.Text(), nullable=True), sa.Column("date_fin", sa.Date(), nullable=True),
sa.Column('formation_scodoc', sa.Integer(), nullable=True), sa.Column("formation_text", sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['entreprise_id'], ['entreprises.id'], ondelete='cascade'), sa.Column("formation_scodoc", sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id') sa.ForeignKeyConstraint(
["entreprise_id"], ["entreprises.id"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
) )
op.create_table('entreprise_offre', op.create_table(
sa.Column('id', sa.Integer(), nullable=False), "entreprise_offre",
sa.Column('entreprise_id', sa.Integer(), nullable=True), sa.Column("id", sa.Integer(), nullable=False),
sa.Column('date_ajout', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), sa.Column("entreprise_id", sa.Integer(), nullable=True),
sa.Column('intitule', sa.Text(), nullable=True), sa.Column(
sa.Column('description', sa.Text(), nullable=True), "date_ajout",
sa.Column('type_offre', sa.Text(), nullable=True), sa.DateTime(timezone=True),
sa.Column('missions', sa.Text(), nullable=True), server_default=sa.text("now()"),
sa.Column('duree', sa.Text(), nullable=True), nullable=True,
sa.ForeignKeyConstraint(['entreprise_id'], ['entreprises.id'], ondelete='cascade'), ),
sa.PrimaryKeyConstraint('id') 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"], ondelete="cascade"
),
sa.PrimaryKeyConstraint("id"),
) )
op.create_table('entreprise_envoi_offre', op.create_table(
sa.Column('id', sa.Integer(), nullable=False), "entreprise_envoi_offre",
sa.Column('user_id', sa.Integer(), nullable=True), sa.Column("id", sa.Integer(), nullable=False),
sa.Column('offre_id', sa.Integer(), nullable=True), sa.Column("sender_id", sa.Integer(), nullable=True),
sa.Column('date_envoi', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True), sa.Column("receiver_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['offre_id'], ['entreprise_offre.id'], ), sa.Column("offre_id", sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), sa.Column(
sa.PrimaryKeyConstraint('id') "date_envoi",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
),
sa.ForeignKeyConstraint(
["offre_id"],
["entreprise_offre.id"],
),
sa.ForeignKeyConstraint(
["sender_id"],
["user.id"],
),
sa.ForeignKeyConstraint(
["receiver_id"],
["user.id"],
),
sa.PrimaryKeyConstraint("id"),
) )
op.drop_constraint('entreprise_contact_entreprise_corresp_id_fkey', 'entreprise_contact', type_='foreignkey') op.drop_constraint(
op.drop_table('entreprise_correspondant') "entreprise_contact_entreprise_corresp_id_fkey",
op.add_column('entreprise_contact', sa.Column('nom', sa.Text(), nullable=True)) "entreprise_contact",
op.add_column('entreprise_contact', sa.Column('prenom', sa.Text(), nullable=True)) type_="foreignkey",
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.drop_table("entreprise_correspondant")
op.add_column('entreprise_contact', sa.Column('poste', sa.Text(), nullable=True)) op.add_column("entreprise_contact", sa.Column("nom", sa.Text(), nullable=True))
op.add_column('entreprise_contact', sa.Column('service', sa.Text(), nullable=True)) op.add_column("entreprise_contact", sa.Column("prenom", sa.Text(), nullable=True))
op.drop_column('entreprise_contact', 'description') op.add_column(
op.drop_column('entreprise_contact', 'enseignant') "entreprise_contact", sa.Column("telephone", sa.Text(), nullable=True)
op.drop_column('entreprise_contact', 'date') )
op.drop_column('entreprise_contact', 'type_contact') op.add_column("entreprise_contact", sa.Column("mail", sa.Text(), nullable=True))
op.drop_column('entreprise_contact', 'etudid') op.add_column("entreprise_contact", sa.Column("poste", sa.Text(), nullable=True))
op.drop_column('entreprise_contact', 'entreprise_corresp_id') 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.add_column("entreprises", sa.Column("siret", sa.Text(), nullable=True))
op.drop_index('ix_entreprises_dept_id', table_name='entreprises') op.drop_index("ix_entreprises_dept_id", table_name="entreprises")
op.drop_constraint('entreprises_dept_id_fkey', 'entreprises', type_='foreignkey') op.drop_constraint("entreprises_dept_id_fkey", "entreprises", type_="foreignkey")
op.drop_column('entreprises', 'qualite_relation') op.drop_column("entreprises", "qualite_relation")
op.drop_column('entreprises', 'note') op.drop_column("entreprises", "note")
op.drop_column('entreprises', 'contact_origine') op.drop_column("entreprises", "contact_origine")
op.drop_column('entreprises', 'plus10salaries') op.drop_column("entreprises", "plus10salaries")
op.drop_column('entreprises', 'privee') op.drop_column("entreprises", "privee")
op.drop_column('entreprises', 'secteur') op.drop_column("entreprises", "secteur")
op.drop_column('entreprises', 'date_creation') op.drop_column("entreprises", "date_creation")
op.drop_column('entreprises', 'dept_id') op.drop_column("entreprises", "dept_id")
op.drop_column('entreprises', 'localisation') op.drop_column("entreprises", "localisation")
# ### end Alembic commands ### # ### end Alembic commands ###
def downgrade(): def downgrade():
# ### commands auto generated by Alembic - please adjust! ### # ### commands auto generated by Alembic - please adjust! ###
op.add_column('entreprises', sa.Column('localisation', sa.TEXT(), autoincrement=False, nullable=True)) op.add_column(
op.add_column('entreprises', sa.Column('dept_id', sa.INTEGER(), autoincrement=False, nullable=True)) "entreprises",
op.add_column('entreprises', sa.Column('date_creation', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True)) sa.Column("localisation", sa.TEXT(), 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.add_column(
op.drop_column('entreprise_contact', 'service') "entreprises",
op.drop_column('entreprise_contact', 'poste') sa.Column("dept_id", sa.INTEGER(), autoincrement=False, nullable=True),
op.drop_column('entreprise_contact', 'mail') )
op.drop_column('entreprise_contact', 'telephone') op.add_column(
op.drop_column('entreprise_contact', 'prenom') "entreprises",
op.drop_column('entreprise_contact', 'nom') 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_envoi_offre")
op.drop_table('entreprise_offre') op.drop_table("entreprise_offre")
op.drop_table('entreprise_etudiant') op.drop_table("entreprise_etudiant")
op.drop_table('entreprise_log') op.drop_table("entreprise_log")
# ### end Alembic commands ### # ### end Alembic commands ###