Skip to content

Commit

Permalink
feat(db): add hierarchy type area
Browse files Browse the repository at this point in the history
Model & migration
  • Loading branch information
Maxime Vergez committed Nov 6, 2023
1 parent d17afae commit b0b4e24
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""add areas types size hierarchy
Revision ID: f22d70b8fcfa
Revises: f7374cd6e38d
Create Date: 2023-05-24 17:42:23.959298
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f22d70b8fcfa'
down_revision = 'f7374cd6e38d'
branch_labels = None
depends_on = None


def upgrade():
op.execute("""
ALTER TABLE ref_geo.bib_areas_types
ADD COLUMN size_hierarchy INT default NULL;
COMMENT ON COLUMN ref_geo.bib_areas_types.size_hierarchy IS
'Diamètre moyen en mètres de ce type zone. Permet d''établir une hiérarchie des types '
'de zone géographique. Utile pour le floutage des observations.' ;
""")

op.execute("""
UPDATE ref_geo.bib_areas_types SET size_hierarchy = 200000 WHERE type_code = 'REG' ;
UPDATE ref_geo.bib_areas_types SET size_hierarchy = 75000 WHERE type_code = 'DEP' ;
UPDATE ref_geo.bib_areas_types SET size_hierarchy = 5000 WHERE type_code = 'COM' ;
UPDATE ref_geo.bib_areas_types SET size_hierarchy = 10000 WHERE type_code = 'M10' ;
UPDATE ref_geo.bib_areas_types SET size_hierarchy = 5000 WHERE type_code = 'M5' ;
UPDATE ref_geo.bib_areas_types SET size_hierarchy = 1000 WHERE type_code = 'M1' ;
""")


def downgrade():
op.execute("""
ALTER TABLE ref_geo.bib_areas_types
DROP COLUMN size_hierarchy;
""")
1 change: 1 addition & 0 deletions src/ref_geo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class BibAreasTypes(db.Model):
ref_name = db.Column(db.Unicode)
ref_version = db.Column(db.Integer)
num_version = db.Column(db.Unicode)
size_hierarchy = db.Column(db.Integer)


cor_areas = db.Table(
Expand Down

0 comments on commit b0b4e24

Please sign in to comment.