From 4557c503625f37019f0c4bb4cc97c5baa841fa3a Mon Sep 17 00:00:00 2001 From: "joel.clement" Date: Tue, 28 Feb 2023 13:50:00 +0100 Subject: [PATCH] correct area_name for communes --- CHANGELOG.md | 7 +++ .../fda887e7b578_correct_area_name_for_COM.py | 43 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/ref_geo/migrations/versions/fda887e7b578_correct_area_name_for_COM.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3377b..12590e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +1.2.3 (unreleased) +------------------ + +**🐛 Corrections** + +* Nom des communes (branche alembic `ref_geo_fr_municipalities`): correction des caractères `¼` et `½` en `Œ` et `œ` + 1.2.1 (2022-11-21) ------------------ diff --git a/src/ref_geo/migrations/versions/fda887e7b578_correct_area_name_for_COM.py b/src/ref_geo/migrations/versions/fda887e7b578_correct_area_name_for_COM.py new file mode 100644 index 0000000..8347332 --- /dev/null +++ b/src/ref_geo/migrations/versions/fda887e7b578_correct_area_name_for_COM.py @@ -0,0 +1,43 @@ +"""empty message + +Revision ID: fda887e7b578 +Revises: 0dfdbfbccd63 +Create Date: 2023-02-28 13:25:40.908589 + +""" +from alembic import op +from utils_flask_sqla.migrations.utils import logger + + +# revision identifiers, used by Alembic. +revision = "fda887e7b578" +down_revision = "0dfdbfbccd63" +branch_labels = None +depends_on = None + + +def upgrade(): + logger.info("Correct area_name for communes (for characters Œ and œ)") + op.execute( + f""" + update ref_geo.l_areas + set area_name = replace(area_name, '¼', 'Œ') + where area_name like '%¼%'; + update ref_geo.l_areas + set area_name = replace(area_name, '½', 'œ') + where area_name like '%½%'; +""" + ) + + +def downgrade(): + op.execute( + f""" + update ref_geo.l_areas + set area_name = replace(area_name, 'Œ', '¼') + where area_name like '%Œ%'; + update ref_geo.l_areas + set area_name = replace(area_name, 'œ', '½') + where area_name like '%œ%'; +""" + )