Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cgscop_liste_ministere
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Le Filament
Confédération Générale des SCOP
cgscop_liste_ministere
Commits
ebed54a6
Commit
ebed54a6
authored
3 years ago
by
Migodoo
Browse files
Options
Downloads
Patches
Plain Diff
[fix] migration script
parent
287a9262
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
migrations/13.0.1.0.0/post-migration.py
+39
-0
39 additions, 0 deletions
migrations/13.0.1.0.0/post-migration.py
migrations/13.0.1.0.0/pre-migration.py
+9
-24
9 additions, 24 deletions
migrations/13.0.1.0.0/pre-migration.py
with
48 additions
and
24 deletions
migrations/13.0.1.0.0/post-migration.py
0 → 100644
+
39
−
0
View file @
ebed54a6
# © 2022 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from
openupgradelib
import
openupgrade
# pylint: disable=W7936
from
psycopg2
import
sql
def
migrate_type_lm
(
env
):
type_id
=
openupgrade
.
get_legacy_name
(
"
type_id
"
)
env
.
cr
.
execute
(
sql
.
SQL
(
"""
UPDATE scop_liste_ministere lm
SET type_lm =
'
subscribe
'
WHERE %(type_id)s = 1;
"""
%
{
"
type_id
"
:
type_id
,
},
),
)
env
.
cr
.
execute
(
sql
.
SQL
(
"""
UPDATE scop_liste_ministere lm
SET type_lm =
'
renew
'
WHERE %(type_id)s = 2;
"""
%
{
"
type_id
"
:
type_id
,
},
),
)
@openupgrade.migrate
()
def
migrate
(
env
,
version
):
migrate_type_lm
(
env
)
This diff is collapsed.
Click to expand it.
migrations/13.0.1.0.0/pre-migration.py
+
9
−
24
View file @
ebed54a6
...
...
@@ -14,7 +14,8 @@ _table_renames = [
(
"
liste_ministere_prestataires
"
,
"
scop_liste_ministere_prestataires
"
),
(
"
liste_ministere_domaine_scic
"
,
"
scop_liste_ministere_domaine_scic
"
),
(
"
liste_ministere_politique_action
"
,
"
scop_liste_ministere_politique_action
"
),
(
"
liste_ministere_cae
"
,
"
scop_liste_ministere_cae
"
),
(
"
liste_ministere_inscription_wizard
"
,
"
scop_liste_ministere_inscription_wizard
"
),
(
"
liste_ministere_renouvellement_wizard
"
,
"
scop_liste_ministere_renouvellement_wizard
"
),
]
_model_renames
=
[
(
"
liste.ministere
"
,
"
scop.liste.ministere
"
),
...
...
@@ -26,35 +27,19 @@ _model_renames = [
(
"
liste.ministere.prestataires
"
,
"
scop.liste.ministere.prestataires
"
),
(
"
liste.ministere.domaine.scic
"
,
"
scop.liste.ministere.domaine.scic
"
),
(
"
liste.ministere.politique.action
"
,
"
scop.liste.ministere.politique.action
"
),
(
"
liste.ministere.cae
"
,
"
scop.liste.ministere.cae
"
),
(
"
liste.ministere.inscription.wizard
"
,
"
scop.liste.ministere.inscription.wizard
"
),
(
"
liste.ministere.renouvellement.wizard
"
,
"
scop.liste.ministere.renouvellement.wizard
"
),
]
def
migrate_type_lm
(
env
):
openupgrade
.
logged_query
(
env
.
cr
,
sql
.
SQL
(
"""
UPDATE scop_liste_ministere lm
SET type_lm =
"
subscribe
"
WHERE type_id = 1;
"""
,
).
format
(
sql
.
Identifier
(
openupgrade
.
get_legacy_name
(
"
mass_editing_id
"
))),
)
openupgrade
.
logged_query
(
env
.
cr
,
sql
.
SQL
(
"""
UPDATE scop_liste_ministere lm
SET type_lm =
"
renew
"
WHERE type_id = 2;
"""
,
).
format
(
sql
.
Identifier
(
openupgrade
.
get_legacy_name
(
"
mass_editing_id
"
))),
)
column_renames
=
{
"
scop_liste_ministere
"
:
[(
"
type_id
"
,
None
)],
}
@openupgrade.migrate
()
def
migrate
(
env
,
version
):
openupgrade
.
rename_models
(
env
.
cr
,
_model_renames
)
openupgrade
.
rename_tables
(
env
.
cr
,
_table_renames
)
migrate_type_lm
(
env
)
openupgrade
.
rename_columns
(
env
.
cr
,
column_renames
)
# migrate_type_lm(env)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment