joining table allocation to actifs

This commit is contained in:
2023-01-29 18:11:40 +01:00
parent 4a55f94551
commit f8023701a4
14 changed files with 111 additions and 272 deletions

View File

@@ -1,81 +0,0 @@
"""add portfolio tables
Revision ID: 19d939dbc6d0
Revises: 7995372bd306
Create Date: 2023-01-23 14:49:31.713228
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '19d939dbc6d0'
down_revision = '7995372bd306'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('actifs',
sa.Column('no_id', sa.Integer(), nullable=False),
sa.Column('symbole', sa.Unicode(length=45), nullable=False),
sa.Column('libelle', sa.Unicode(length=45), nullable=False),
sa.Column('classe', sa.Unicode(length=45), nullable=False),
sa.Column('nombre', sa.Integer(), nullable=True),
sa.Column('cours', sa.Float(), nullable=True),
sa.Column('pru', sa.Float(), nullable=True),
sa.Column('valeur', sa.Float(), nullable=True),
sa.Column('plus_value', sa.Float(), nullable=True),
sa.Column('pc_plusvalue', sa.Float(), nullable=True),
sa.Column('rendement', sa.Float(), nullable=True),
sa.Column('pc_rdt', sa.Float(), nullable=True),
sa.Column('pc_allocation', sa.Float(), nullable=True),
sa.Column('ter', sa.Float(), nullable=True),
sa.Column('ter_pondere', sa.Float(), nullable=True),
sa.Column('devise', sa.Unicode(length=45), nullable=True),
sa.Column('parite', sa.Float(), nullable=True),
sa.Column('website', sa.Unicode(length=100), nullable=True),
sa.Column('modif_le', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('no_id', name=op.f('pk_actifs')),
sa.UniqueConstraint('symbole', name=op.f('uq_actifs_symbole'))
)
op.create_index('symbole_index', 'actifs', ['symbole'], unique=False)
op.create_table('allocation',
sa.Column('no_cat', sa.Integer(), nullable=False),
sa.Column('classe', sa.Unicode(length=45), nullable=False),
sa.Column('pc_cible', sa.Integer(), nullable=True),
sa.Column('pc_atteint', sa.Float(), nullable=True),
sa.Column('valeur', sa.Float(), nullable=True),
sa.PrimaryKeyConstraint('no_cat', name=op.f('pk_allocation'))
)
op.create_table('classes',
sa.Column('classe', sa.Unicode(), nullable=False),
sa.Column('type', sa.Unicode(length=45), nullable=True),
sa.Column('ordre', sa.Integer(), nullable=True),
sa.Column('bg_color', sa.Unicode(length=45), nullable=True),
sa.PrimaryKeyConstraint('classe', name=op.f('pk_classes'))
)
op.create_index('ordre_index', 'classes', ['ordre'], unique=False)
op.create_table('histo',
sa.Column('no_id', sa.Integer(), nullable=False),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('mvt_cash', sa.Float(), nullable=True),
sa.Column('valeur_pf', sa.Float(), nullable=True),
sa.Column('nb_part', sa.Float(), nullable=True),
sa.Column('val_part', sa.Float(), nullable=True),
sa.Column('cours_ref', sa.Float(), nullable=True),
sa.Column('val_part_ref', sa.Float(), nullable=True),
sa.PrimaryKeyConstraint('no_id', name=op.f('pk_histo'))
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('histo')
op.drop_index('ordre_index', table_name='classes')
op.drop_table('classes')
op.drop_table('allocation')
op.drop_index('symbole_index', table_name='actifs')
op.drop_table('actifs')
# ### end Alembic commands ###

View File

@@ -1,26 +0,0 @@
"""add portfolio tables
Revision ID: 7995372bd306
Revises: fe8f8a5bfdb5
Create Date: 2023-01-23 14:43:22.632056
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7995372bd306'
down_revision = 'fe8f8a5bfdb5'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###

View File

@@ -1,26 +0,0 @@
"""add portfolio tables
Revision ID: fe8f8a5bfdb5
Revises:
Create Date: 2023-01-23 14:42:10.171291
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fe8f8a5bfdb5'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###

View File

@@ -1,30 +0,0 @@
"""added relationship allocation-classe
Revision ID: 42a297861f20
Revises: 19d939dbc6d0
Create Date: 2023-01-26 14:23:42.771763
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '42a297861f20'
down_revision = '19d939dbc6d0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('allocation', sa.Column('classe_id', sa.Unicode(length=45), nullable=True))
op.create_foreign_key(op.f('fk_allocation_classe_id_classes'), 'allocation', 'classes', ['classe_id'], ['classe'])
op.drop_column('allocation', 'classe')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('allocation', sa.Column('classe', sa.VARCHAR(length=45), nullable=False))
op.drop_constraint(op.f('fk_allocation_classe_id_classes'), 'allocation', type_='foreignkey')
op.drop_column('allocation', 'classe_id')
# ### end Alembic commands ###

View File

@@ -1,34 +0,0 @@
"""added relationship allocation-classe
Revision ID: bbfb79cb9dad
Revises: 42a297861f20
Create Date: 2023-01-26 14:41:29.955558
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'bbfb79cb9dad'
down_revision = '42a297861f20'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('allocation',
sa.Column('no_cat', sa.Integer(), nullable=False),
sa.Column('classe_id', sa.Unicode(length=45), nullable=True),
sa.Column('pc_cible', sa.Integer(), nullable=True),
sa.Column('pc_atteint', sa.Float(), nullable=True),
sa.Column('valeur', sa.Float(), nullable=True),
sa.ForeignKeyConstraint(['classe_id'], ['classes.classe'], name=op.f('fk_allocation_classe_id_classes')),
sa.PrimaryKeyConstraint('no_cat', name=op.f('pk_allocation'))
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('allocation')
# ### end Alembic commands ###

View File

@@ -0,0 +1,42 @@
"""added foreign key to allocation
Revision ID: b8f8216d72c7
Revises:
Create Date: 2023-01-29 12:20:48.097107
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b8f8216d72c7'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('allocation',
sa.Column('no_cat', sa.Integer(), nullable=False),
sa.Column('classe', sa.Unicode(length=45), nullable=True),
sa.Column('pc_cible', sa.Integer(), nullable=True),
sa.Column('pc_atteint', sa.Float(), nullable=True),
sa.Column('pc_ecart', sa.Float(), nullable=True),
sa.Column('valeur', sa.Float(), nullable=True),
sa.Column('type', sa.Unicode(length=45), nullable=True),
sa.Column('ordre', sa.Integer(), nullable=True),
sa.Column('bg_color', sa.Unicode(length=45), nullable=True),
sa.ForeignKeyConstraint(['classe'], ['actifs.classe'], name=op.f('fk_allocation_classe_actifs')),
sa.PrimaryKeyConstraint('no_cat', name=op.f('pk_allocation'))
)
op.create_index('classe_index', 'allocation', ['classe'], unique=False)
op.create_index('ordre_index', 'allocation', ['ordre'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('ordre_index', table_name='allocation')
op.drop_index('classe_index', table_name='allocation')
op.drop_table('allocation')
# ### end Alembic commands ###