-
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.
[Monitoring] Add t_observations.cd_nom foreign key
- Loading branch information
1 parent
681c799
commit d13fe4f
Showing
2 changed files
with
41 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
backend/geonature/migrations/versions/5b61bcaa18da_monitoring_add_cd_nom_foreign_key.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,40 @@ | ||
"""[monitoring] Add cd_nom foreign key | ||
Revision ID: 5b61bcaa18da | ||
Revises: 2894b3c03c66 | ||
Create Date: 2025-01-07 14:28:20.475116 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = "5b61bcaa18da" | ||
down_revision = "2894b3c03c66" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# Création clé étrangère sur la table t_observations | ||
op.create_foreign_key( | ||
"fk_t_observations_cd_nom_fkey", | ||
source_schema="gn_monitoring", | ||
source_table="t_observations", | ||
local_cols=["cd_nom"], | ||
referent_schema="taxonomie", | ||
referent_table="taxref", | ||
remote_cols=["cd_nom"], | ||
onupdate=None, | ||
ondelete=None, | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_constraint( | ||
"fk_t_observations_cd_nom_fkey", | ||
table_name="t_observations", | ||
schema="gn_monitoring", | ||
) |