Skip to content

Commit 00a13ab

Browse files
committed
[FIX] fix migration if updating old version
1 parent 56d7993 commit 00a13ab

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

pattern_import_export/migrations/12.0.4.0.0/post-migrate.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66

77
@openupgrade.migrate()
88
def migrate(env, version):
9+
params = {}
10+
for field, default_value in [
11+
("pattern_file", "NULL"),
12+
("pattern_file_name", "NULL"),
13+
("pattern_last_generation_date", "NULL"),
14+
("partial_commit", "True"),
15+
("flush_step", "500"),
16+
("export_format", "NULL"),
17+
]:
18+
if openupgrade.column_exists(env.cr, "ir_exports", field):
19+
params[field] = '"{}"'.format(field)
20+
else:
21+
params[field] = default_value
22+
923
env.cr.execute(
1024
"""
1125
INSERT INTO pattern_config (
@@ -20,15 +34,17 @@ def migrate(env, version):
2034
)
2135
SELECT
2236
use_description,
23-
pattern_file,
24-
pattern_file_name,
25-
pattern_last_generation_date,
26-
export_format,
27-
partial_commit,
28-
flush_step,
37+
{p[pattern_file]},
38+
{p[pattern_file_name]},
39+
{p[pattern_last_generation_date]},
40+
{p[export_format]},
41+
{p[partial_commit]},
42+
{p[flush_step]},
2943
id
3044
FROM ir_exports WHERE is_pattern IS TRUE
31-
"""
45+
""".format(
46+
p=params
47+
)
3248
)
3349

3450
env.cr.execute(

0 commit comments

Comments
 (0)