← Back to team overview

credativ team mailing list archive

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

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-server/6.0-lp983731-rename_orm_table_sequences into lp:openupgrade-server/6.0 with lp:~therp-nl/openupgrade-server/6.0-API_and_loading_improvements as a prerequisite.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)
Related bugs:
  Bug #983731 in OpenUpgrade Addons: "CRM module is not yet covered"
  https://bugs.launchpad.net/openupgrade-addons/+bug/983731

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-server/6.0-lp983731-rename_orm_table_sequences/+merge/109213
-- 
https://code.launchpad.net/~therp-nl/openupgrade-server/6.0-lp983731-rename_orm_table_sequences/+merge/109213
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-server/6.0-lp983731-rename_orm_table_sequences into lp:openupgrade-server/6.0.
=== modified file 'bin/openupgrade/openupgrade.py'
--- bin/openupgrade/openupgrade.py	2012-06-07 18:57:21 +0000
+++ bin/openupgrade/openupgrade.py	2012-06-07 18:57:21 +0000
@@ -108,9 +108,18 @@
 def rename_tables(cr, table_spec):
     """
     Rename tables. Typically called in the pre script.
-    :param column_spec: a list of tuples (old table name, new table name).
+    This function also renames the id sequence if it exists and if it is
+    not modified in the same run.
+
+    :param table_spec: a list of tuples (old table name, new table name).
 
     """
+    # Append id sequences
+    to_rename = [x[0] for x in table_spec]
+    for old, new in list(table_spec):
+        if (table_exists(cr, old + '_id_seq') and
+            old + '_id_seq' not in to_rename): 
+            table_spec.append((old + '_id_seq', new + '_id_seq'))
     for (old, new) in table_spec:
         logger.info("table %s: renaming to %s",
                     old, new)
@@ -119,7 +128,7 @@
 def rename_models(cr, model_spec):
     """
     Rename models. Typically called in the pre script.
-    :param column_spec: a list of tuples (old model name, new model name).
+    :param model_spec: a list of tuples (old model name, new model name).
     
     Use case: if a model changes name, but still implements equivalent
     functionality you will want to update references in for instance


Follow ups