Skip to content

Commit

Permalink
feat/add-constraint-t_habitats.id_nomenclature_community_interest
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux authored and bouttier committed Feb 21, 2024
1 parent 9aea5a2 commit f990f7f
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""add constraint to t_habitats.id_nomenclature_community_interest content type
Revision ID: fcf1e091b636
Revises: 167d69b42d25
Create Date: 2024-02-07 16:33:41.381934
"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "fcf1e091b636"
down_revision = "167d69b42d25"
branch_labels = None
depends_on = None

table = "pr_occhab.t_habitats"
constraint = "check_t_habitats_community_interest"
check = "(ref_nomenclatures.check_nomenclature_type_by_mnemonique(id_nomenclature_community_interest, 'HAB_INTERET_COM'::character varying))"


def upgrade():
op.execute(
f"""
ALTER TABLE ONLY {table}
ADD CONSTRAINT {constraint} CHECK {check} NOT VALID
"""
)


def downgrade():
op.execute(
f"""
ALTER TABLE {table}
DROP CONSTRAINT {constraint};
"""
)

0 comments on commit f990f7f

Please sign in to comment.