Merge lp:~therp-nl/openupgrade-server/6.0-lp983731-rename_orm_table_sequences into lp:openupgrade-server/6.0

Proposed by Stefan Rijnhart (Opener) on 2012-06-07
Status: Merged
Merged at revision: 3490
Proposed branch: lp:~therp-nl/openupgrade-server/6.0-lp983731-rename_orm_table_sequences
Merge into: lp:openupgrade-server/6.0
Prerequisite: lp:~therp-nl/openupgrade-server/6.0-API_and_loading_improvements
Diff against target: 32 lines (+11/-2)
1 file modified
bin/openupgrade/openupgrade.py (+11/-2)
To merge this branch: bzr merge lp:~therp-nl/openupgrade-server/6.0-lp983731-rename_orm_table_sequences
Reviewer Review Type Date Requested Status
OpenUpgrade Committers 2012-06-07 Pending
Review via email: mp+109213@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/openupgrade/openupgrade.py'
2--- bin/openupgrade/openupgrade.py 2012-06-07 18:57:21 +0000
3+++ bin/openupgrade/openupgrade.py 2012-06-07 18:57:21 +0000
4@@ -108,9 +108,18 @@
5 def rename_tables(cr, table_spec):
6 """
7 Rename tables. Typically called in the pre script.
8- :param column_spec: a list of tuples (old table name, new table name).
9+ This function also renames the id sequence if it exists and if it is
10+ not modified in the same run.
11+
12+ :param table_spec: a list of tuples (old table name, new table name).
13
14 """
15+ # Append id sequences
16+ to_rename = [x[0] for x in table_spec]
17+ for old, new in list(table_spec):
18+ if (table_exists(cr, old + '_id_seq') and
19+ old + '_id_seq' not in to_rename):
20+ table_spec.append((old + '_id_seq', new + '_id_seq'))
21 for (old, new) in table_spec:
22 logger.info("table %s: renaming to %s",
23 old, new)
24@@ -119,7 +128,7 @@
25 def rename_models(cr, model_spec):
26 """
27 Rename models. Typically called in the pre script.
28- :param column_spec: a list of tuples (old model name, new model name).
29+ :param model_spec: a list of tuples (old model name, new model name).
30
31 Use case: if a model changes name, but still implements equivalent
32 functionality you will want to update references in for instance

Subscribers

People subscribed via source and target branches