-
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.
Merge pull request #11 from mvergez/feat/add-hierarchy-type-area
feat(db): add hierarchy type area
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
"""add areas types size hierarchy | ||
Revision ID: f22d70b8fcfa | ||
Revises: 795f6ea8ec45 | ||
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 = "bc2fcc772b46" | ||
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