ajout des relations
This commit is contained in:
parent
42334c7946
commit
431df65c8d
@ -1,5 +1,20 @@
|
||||
from app import db
|
||||
|
||||
Ressources_ACs = db.Table("Ressources_ACs",
|
||||
db.Column("Ressource_code", db.String(4), db.ForeignKey("ressource.code")),
|
||||
db.Column("AC_code", db.String(6), db.ForeignKey("AC.code"))
|
||||
)
|
||||
|
||||
Ressources_SAEs = db.Table("Ressources_SAEs",
|
||||
db.Column("Ressource_code", db.String(4), db.ForeignKey("ressource.code")),
|
||||
db.Column("SAE_code", db.String(5), db.ForeignKey("SAE.code"))
|
||||
)
|
||||
|
||||
SAEs_ACs = db.Table("SAEs_ACs",
|
||||
db.Column("SAE_code", db.String(5), db.ForeignKey("SAE.code")),
|
||||
db.Column("AC_code", db.String(6), db.ForeignKey("AC.code"))
|
||||
)
|
||||
|
||||
class PN(db.Model):
|
||||
code = db.Column(db.String(3), primary_key = True)
|
||||
nom = db.Column(db.String(255))
|
||||
@ -13,7 +28,7 @@ class PN(db.Model):
|
||||
class AC(db.Model):
|
||||
code = db.Column(db.String(6), primary_key = True)
|
||||
titre = db.Column(db.String(255))
|
||||
saes = db.Column(db.String(255))
|
||||
saes = db.relationship("SAE", secondary=SAEs_ACs, lazy=True, backref=db.backref("acs", lazy=True))
|
||||
|
||||
def __repr__(self):
|
||||
return "<AC {}>".format(self.code)
|
||||
@ -27,8 +42,8 @@ class SAE(db.Model):
|
||||
projet = db.Column(db.String(3))
|
||||
description = db.Column(db.Text())
|
||||
coef = db.Column(db.String(255))
|
||||
acs = db.Column(db.String(255))
|
||||
ressources = db.Column(db.String(255))
|
||||
#acs = db.relationship("AC", secondary=SAEs_ACs, lazy=True, backref=db.backref("saes", lazy=True))
|
||||
ressources = db.relationship("Ressource", secondary=Ressources_SAEs, lazy=True, backref=db.backref("saes", lazy=True))
|
||||
livrables = db.Column(db.Text())
|
||||
motscles = db.Column(db.String(255))
|
||||
|
||||
@ -42,8 +57,8 @@ class Ressource(db.Model):
|
||||
heures_formation = db.Column(db.String(3))
|
||||
heures_tp = db.Column(db.String(3))
|
||||
coef = db.Column(db.String(255))
|
||||
acs = db.Column(db.String(255))
|
||||
saes = db.Column(db.String(255))
|
||||
#acs = db.relationship("AC", secondary=Ressources_ACs, lazy=True, backref=db.backref("ressources", lazy=True))
|
||||
#saes = db.relationship("SAE", secondary=Ressources_SAEs, lazy=True, backref=db.backref("ressources", lazy=True))
|
||||
prerequis = db.Column(db.String(255))
|
||||
contexte = db.Column(db.Text())
|
||||
contenu = db.Column(db.Text())
|
||||
|
57
migrations/versions/e52d97e91e29_.py
Normal file
57
migrations/versions/e52d97e91e29_.py
Normal file
@ -0,0 +1,57 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: e52d97e91e29
|
||||
Revises: c000b3a8d714
|
||||
Create Date: 2021-05-07 14:03:45.369279
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e52d97e91e29'
|
||||
down_revision = 'c000b3a8d714'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('Ressources_ACs',
|
||||
sa.Column('Ressource_code', sa.String(length=4), nullable=True),
|
||||
sa.Column('AC_code', sa.String(length=6), nullable=True),
|
||||
sa.ForeignKeyConstraint(['AC_code'], ['AC.code'], ),
|
||||
sa.ForeignKeyConstraint(['Ressource_code'], ['ressource.code'], )
|
||||
)
|
||||
op.create_table('Ressources_SAEs',
|
||||
sa.Column('Ressource_code', sa.String(length=4), nullable=True),
|
||||
sa.Column('SAE_code', sa.String(length=5), nullable=True),
|
||||
sa.ForeignKeyConstraint(['Ressource_code'], ['ressource.code'], ),
|
||||
sa.ForeignKeyConstraint(['SAE_code'], ['SAE.code'], )
|
||||
)
|
||||
op.create_table('SAEs_ACs',
|
||||
sa.Column('SAE_code', sa.String(length=5), nullable=True),
|
||||
sa.Column('AC_code', sa.String(length=6), nullable=True),
|
||||
sa.ForeignKeyConstraint(['AC_code'], ['AC.code'], ),
|
||||
sa.ForeignKeyConstraint(['SAE_code'], ['SAE.code'], )
|
||||
)
|
||||
op.drop_column('AC', 'saes')
|
||||
op.drop_column('SAE', 'ressources')
|
||||
op.drop_column('SAE', 'acs')
|
||||
op.drop_column('ressource', 'saes')
|
||||
op.drop_column('ressource', 'acs')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('ressource', sa.Column('acs', sa.VARCHAR(length=255), nullable=True))
|
||||
op.add_column('ressource', sa.Column('saes', sa.VARCHAR(length=255), nullable=True))
|
||||
op.add_column('SAE', sa.Column('acs', sa.VARCHAR(length=255), nullable=True))
|
||||
op.add_column('SAE', sa.Column('ressources', sa.VARCHAR(length=255), nullable=True))
|
||||
op.add_column('AC', sa.Column('saes', sa.VARCHAR(length=255), nullable=True))
|
||||
op.drop_table('SAEs_ACs')
|
||||
op.drop_table('Ressources_SAEs')
|
||||
op.drop_table('Ressources_ACs')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue
Block a user