Skip to content

Commit

Permalink
Rename alembic branches and remove code profil 3,4 (PnX-SI#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl authored Aug 14, 2024
1 parent 0ef55f9 commit a8bac38
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ jobs:
-r requirements-dev.in
- name: Install database
run: |
flask db upgrade taxhub@head -x local-srid=2154
flask db upgrade taxhub-standalone@head
flask db upgrade taxhub-standalone@head -x local-srid=2154
flask db upgrade taxhub-standalone-sample@head
flask db upgrade ref_geo_fr_departments@head
flask db autoupgrade
flask db status
Expand Down
63 changes: 63 additions & 0 deletions apptax/migrations/versions/1f7b958108ed_remove_code_profil_3_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
"""Remove code_profil 3, 4
Revision ID: 1f7b958108ed
Revises: 64d38dbe7739
Create Date: 2024-08-14 12:13:46.319115
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "1f7b958108ed"
down_revision = "64d38dbe7739"
branch_labels = None
depends_on = None


def upgrade():
# Mise à jour des droits utilisateurs
op.execute(
"""
UPDATE utilisateurs.cor_role_app_profil cor SET id_profil = (SELECT id_profil FROM utilisateurs.t_profils WHERE code_profil = '2' LIMIT 1)
FROM utilisateurs.t_applications app
WHERE cor.id_application = app.id_application AND app.code_application = 'TH'
AND id_profil IN (SELECT id_profil FROM utilisateurs.t_profils WHERE code_profil IN ('3', '4'))
AND NOT EXISTS (
SELECT 1
FROM utilisateurs.cor_role_app_profil cor, utilisateurs.t_applications app
WHERE cor.id_application = app.id_application AND app.code_application = 'TH'
AND id_profil = (SELECT id_profil FROM utilisateurs.t_profils WHERE code_profil = '2' LIMIT 1)
)
"""
)
# Suppression des profils
op.execute(
"""
DELETE FROM utilisateurs.cor_profil_for_app cor
USING utilisateurs.t_applications app
WHERE cor.id_application = app.id_application
AND app.code_application = 'TH'
AND id_profil IN (SELECT id_profil FROM utilisateurs.t_profils WHERE code_profil IN ('3', '4'));
"""
)


def downgrade():

op.execute(
"""
INSERT INTO utilisateurs.cor_profil_for_app
(id_profil, id_application)
VALUES
(
(SELECT id_profil FROM utilisateurs.t_profils WHERE code_profil = '3'),
(SELECT id_application FROM utilisateurs.t_applications WHERE code_application = 'TH')
), (
(SELECT id_profil FROM utilisateurs.t_profils WHERE code_profil = '4'),
(SELECT id_application FROM utilisateurs.t_applications WHERE code_application = 'TH')
)
"""
)
2 changes: 1 addition & 1 deletion apptax/migrations/versions/3fe8c07741be_taxhub_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# revision identifiers, used by Alembic.
revision = "3fe8c07741be"
down_revision = None
branch_labels = ("taxhub-standalone",)
branch_labels = ("taxhub-standalone-sample",)
depends_on = (
"fa5a90853c45", # taxhub
"72f227e37bdf", # utilisateurs schema samples data
Expand Down
2 changes: 1 addition & 1 deletion apptax/migrations/versions/fa5a90853c45_taxhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# revision identifiers, used by Alembic.
revision = "fa5a90853c45"
down_revision = None
branch_labels = ("taxhub",)
branch_labels = ("taxhub-standalone",)
depends_on = ("fa35dfe5ff27",) # schema utilisateurs


Expand Down
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Ajout du paramètre `API_PREFIX` si on souhaite rajouter in préfixe devant les routes de l'API TaxHub (ne pas renseigné si vous utilisez TaxHub avec GeoNature)
- L'image Docker de TaxHub n'est plus générée pour en raison de son integration à GeoNature (#519)
- suppression du support Amazon S3
- Les branches taxhub et taxhub-admin ont été renommée en taxhub-standalone et taxhub-standalone-sample.



Expand Down
4 changes: 2 additions & 2 deletions install_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ then
flask db stamp 72f227e37bdf # utilisateurs-samples
fi

flask db upgrade taxonomie@head -x local-srid=2154
flask db upgrade taxhub-standalone@head
flask db upgrade taxhub-standalone@head -x local-srid=2154
flask db upgrade taxhub-standalone-sample@head
flask db upgrade ref_geo_fr_departments@head
flask db autoupgrade

Expand Down

0 comments on commit a8bac38

Please sign in to comment.