-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(monitoring, db): add id_import column for each entity in monitor…
…ing model (#3275) * add id_import in monitoring model * feat: add id_import columns in monitoring tables * fix(db): change head of revision to latest in feat/import-monitorings --------- Co-authored-by: Julien Corny <[email protected]> Co-authored-by: jacquesfize <[email protected]>
- Loading branch information
1 parent
38aea2f
commit 2b5f26f
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
backend/geonature/migrations/versions/df277299fdda_add_id_import_column_for_each_entity.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,39 @@ | ||
"""[monitoring] add id_import column for each entity | ||
Revision ID: df277299fdda | ||
Revises: 6734d8f7eb2a | ||
Create Date: 2024-11-28 18:20:49.512808 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "df277299fdda" | ||
down_revision = "a94bea44ab56" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
import_column_name = "id_import" | ||
schema = "gn_monitoring" | ||
entity_tables = ["t_base_sites", "t_base_visits", "t_observations"] | ||
|
||
|
||
def upgrade(): | ||
for table in entity_tables: | ||
op.add_column( | ||
schema=schema, | ||
table_name=table, | ||
column=sa.Column(import_column_name, sa.Integer, nullable=True), | ||
) | ||
|
||
|
||
def downgrade(): | ||
for table in entity_tables: | ||
op.drop_column( | ||
schema=schema, | ||
table_name=table, | ||
column_name=import_column_name, | ||
) |