-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Model & migration
- Loading branch information
Maxime Vergez
committed
Nov 6, 2023
1 parent
d17afae
commit b0b4e24
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/ref_geo/migrations/versions/f22d70b8fcfa_add_areas_types_size_hierarchy.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,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; | ||
""") |
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