forked from PnX-SI/gn_module_monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add association table with alembic
Add model in backend and alembic migration Reviewed-by: andriac [Refs ticket]: #3
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
backend/gn_module_monitoring/migrations/a54bafb13ce8_create_cor_module_category.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""create_cor_module_category | ||
Revision ID: a54bafb13ce8 | ||
Revises: | ||
Create Date: 2022-12-06 16:18:24.512562 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "a54bafb13ce8" | ||
down_revision = "b53bafb13ce8" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
monitorings_schema = "gn_monitoring" | ||
referent_schema = "gn_commons" | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"cor_module_categorie", | ||
sa.Column( | ||
"id_categorie", | ||
sa.Integer(), | ||
sa.ForeignKey( | ||
f"{monitorings_schema}.bib_categorie_site.id_categorie", | ||
name="fk_cor_module_categorie_id_categorie", | ||
ondelete="CASCADE", | ||
onupdate="CASCADE", | ||
), | ||
nullable=False, | ||
), | ||
sa.Column("id_module", sa.Integer(),sa.ForeignKey( | ||
f"{referent_schema}.t_modules.id_module", | ||
name="fk_cor_module_categorie_id_module", | ||
ondelete="CASCADE", | ||
onupdate="CASCADE", | ||
), nullable=False), | ||
sa.PrimaryKeyConstraint("id_categorie", "id_module", name="pk_cor_module_categorie"), | ||
schema=monitorings_schema, | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table("cor_module_categorie", schema=monitorings_schema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters