forked from PnX-SI/TaxHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename alembic branches and remove code profil 3,4 (PnX-SI#541)
- Loading branch information
1 parent
0ef55f9
commit a8bac38
Showing
6 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
apptax/migrations/versions/1f7b958108ed_remove_code_profil_3_4.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,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') | ||
) | ||
""" | ||
) |
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
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
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
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