1
0
forked from ScoDoc/ScoDoc

renomme tables application relations entreprises

This commit is contained in:
Arthur ZHU 2022-01-24 11:16:46 +01:00
parent 2b1a3ee95e
commit d637ffe70c
2 changed files with 177 additions and 12 deletions

View File

@ -2,7 +2,7 @@ from app import db
class Entreprise(db.Model):
__tablename__ = "entreprises"
__tablename__ = "are_entreprises"
id = db.Column(db.Integer, primary_key=True)
siret = db.Column(db.Text)
nom = db.Column(db.Text)
@ -35,10 +35,10 @@ class Entreprise(db.Model):
class EntrepriseContact(db.Model):
__tablename__ = "entreprise_contact"
__tablename__ = "are_entreprise_contact"
id = db.Column(db.Integer, primary_key=True)
entreprise_id = db.Column(
db.Integer, db.ForeignKey("entreprises.id", ondelete="cascade")
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade")
)
nom = db.Column(db.Text)
prenom = db.Column(db.Text)
@ -76,10 +76,10 @@ class EntrepriseContact(db.Model):
class EntrepriseOffre(db.Model):
__tablename__ = "entreprise_offre"
__tablename__ = "are_entreprise_offre"
id = db.Column(db.Integer, primary_key=True)
entreprise_id = db.Column(
db.Integer, db.ForeignKey("entreprises.id", ondelete="cascade")
db.Integer, db.ForeignKey("are_entreprises.id", ondelete="cascade")
)
date_ajout = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
intitule = db.Column(db.Text)
@ -99,7 +99,7 @@ class EntrepriseOffre(db.Model):
class EntrepriseLog(db.Model):
__tablename__ = "entreprise_log"
__tablename__ = "are_entreprise_log"
id = db.Column(db.Integer, primary_key=True)
date = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
authenticated_user = db.Column(db.Text)
@ -108,9 +108,9 @@ class EntrepriseLog(db.Model):
class EntrepriseEtudiant(db.Model):
__tablename__ = "entreprise_etudiant"
__tablename__ = "are_entreprise_etudiant"
id = db.Column(db.Integer, primary_key=True)
entreprise_id = db.Column(db.Integer, db.ForeignKey("entreprises.id"))
entreprise_id = db.Column(db.Integer, db.ForeignKey("are_entreprises.id"))
etudid = db.Column(db.Integer)
type_offre = db.Column(db.Text)
date_debut = db.Column(db.Date)
@ -120,18 +120,18 @@ class EntrepriseEtudiant(db.Model):
class EntrepriseEnvoiOffre(db.Model):
__tablename__ = "entreprise_envoi_offre"
__tablename__ = "are_entreprise_envoi_offre"
id = db.Column(db.Integer, primary_key=True)
sender_id = db.Column(db.Integer, db.ForeignKey("user.id"))
receiver_id = db.Column(db.Integer, db.ForeignKey("user.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("entreprise_offre.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id"))
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())
class EntrepriseEnvoiOffreEtudiant(db.Model):
__tablename__ = "entreprise_envoi_offre_etudiant"
__tablename__ = "are_entreprise_envoi_offre_etudiant"
id = db.Column(db.Integer, primary_key=True)
sender_id = db.Column(db.Integer, db.ForeignKey("user.id"))
receiver_id = db.Column(db.Integer, db.ForeignKey("identite.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("entreprise_offre.id"))
offre_id = db.Column(db.Integer, db.ForeignKey("are_entreprise_offre.id"))
date_envoi = db.Column(db.DateTime(timezone=True), server_default=db.func.now())

View File

@ -0,0 +1,165 @@
"""tables application relations entreprises
Revision ID: ee3f2eab6f08
Revises: f40fbaf5831c
Create Date: 2022-01-24 10:44:09.706261
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = 'ee3f2eab6f08'
down_revision = 'f40fbaf5831c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('are_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('are_entreprises',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('siret', sa.Text(), 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.PrimaryKeyConstraint('id')
)
op.create_table('are_entreprise_contact',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('entreprise_id', sa.Integer(), nullable=True),
sa.Column('nom', sa.Text(), nullable=True),
sa.Column('prenom', sa.Text(), nullable=True),
sa.Column('telephone', sa.Text(), nullable=True),
sa.Column('mail', sa.Text(), nullable=True),
sa.Column('poste', sa.Text(), nullable=True),
sa.Column('service', sa.Text(), nullable=True),
sa.ForeignKeyConstraint(['entreprise_id'], ['are_entreprises.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('are_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'], ['are_entreprises.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('are_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'], ['are_entreprises.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('are_entreprise_envoi_offre',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('sender_id', sa.Integer(), nullable=True),
sa.Column('receiver_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'], ['are_entreprise_offre.id'], ),
sa.ForeignKeyConstraint(['receiver_id'], ['user.id'], ),
sa.ForeignKeyConstraint(['sender_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('are_entreprise_envoi_offre_etudiant',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('sender_id', sa.Integer(), nullable=True),
sa.Column('receiver_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'], ['are_entreprise_offre.id'], ),
sa.ForeignKeyConstraint(['receiver_id'], ['identite.id'], ),
sa.ForeignKeyConstraint(['sender_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_table('entreprise_contact')
op.drop_table('entreprise_correspondant')
op.drop_index('ix_entreprises_dept_id', table_name='entreprises')
op.drop_table('entreprises')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('entreprises',
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('entreprises_id_seq'::regclass)"), autoincrement=True, nullable=False),
sa.Column('nom', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('adresse', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('ville', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('codepostal', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('pays', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('localisation', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('dept_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('date_creation', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=True),
sa.Column('secteur', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('privee', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('plus10salaries', sa.BOOLEAN(), autoincrement=False, nullable=True),
sa.Column('contact_origine', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('note', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('qualite_relation', sa.INTEGER(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['dept_id'], ['departement.id'], name='entreprises_dept_id_fkey'),
sa.PrimaryKeyConstraint('id', name='entreprises_pkey'),
postgresql_ignore_search_path=False
)
op.create_index('ix_entreprises_dept_id', 'entreprises', ['dept_id'], unique=False)
op.create_table('entreprise_correspondant',
sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('entreprise_correspondant_id_seq'::regclass)"), 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'),
postgresql_ignore_search_path=False
)
op.create_table('entreprise_contact',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('entreprise_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('entreprise_corresp_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('etudid', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('type_contact', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('date', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
sa.Column('enseignant', sa.TEXT(), autoincrement=False, nullable=True),
sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['entreprise_corresp_id'], ['entreprise_correspondant.id'], name='entreprise_contact_entreprise_corresp_id_fkey'),
sa.ForeignKeyConstraint(['entreprise_id'], ['entreprises.id'], name='entreprise_contact_entreprise_id_fkey'),
sa.PrimaryKeyConstraint('id', name='entreprise_contact_pkey')
)
op.drop_table('are_entreprise_envoi_offre_etudiant')
op.drop_table('are_entreprise_envoi_offre')
op.drop_table('are_entreprise_offre')
op.drop_table('are_entreprise_etudiant')
op.drop_table('are_entreprise_contact')
op.drop_table('are_entreprises')
op.drop_table('are_entreprise_log')
# ### end Alembic commands ###