← Back to team overview

openerp-community team mailing list archive

lp:~camptocamp/openerp-product-attributes/7.0-fix-1259975-migration-lep into lp:openerp-product-attributes

 

Leonardo Pistone @ camptocamp has proposed merging lp:~camptocamp/openerp-product-attributes/7.0-fix-1259975-migration-lep into lp:openerp-product-attributes.

Requested reviews:
  Product Core Editors (product-core-editors)
Related bugs:
  Bug #1259975 in OpenERP Product Attributes: "product_custom_attributes: migration script fails if installed with -i on a fresh DB"
  https://bugs.launchpad.net/openerp-product-attributes/+bug/1259975

For more details, see:
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-fix-1259975-migration-lep/+merge/198592
-- 
https://code.launchpad.net/~camptocamp/openerp-product-attributes/7.0-fix-1259975-migration-lep/+merge/198592
Your team OpenERP Community is subscribed to branch lp:openerp-product-attributes.
=== modified file 'product_custom_attributes/migrations/7.0.0.2/post-migration.py'
--- product_custom_attributes/migrations/7.0.0.2/post-migration.py	2013-09-30 11:21:33 +0000
+++ product_custom_attributes/migrations/7.0.0.2/post-migration.py	2013-12-11 15:53:04 +0000
@@ -25,11 +25,12 @@
 
 
 def migrate(cr, version):
-    logger.info("Migrating product_custom_attributes from version %s", version)
-    cr.execute("UPDATE product_template pt "
-               "SET attribute_set_id = (SELECT pp.attribute_set_id "
-               "                        FROM product_product pp WHERE "
-               "                        pp.product_tmpl_id = pt.id "
-               "                        LIMIT 1)"
-               "WHERE pt.attribute_set_id IS NULL")
-    cr.execute('ALTER TABLE product_product DROP COLUMN attribute_set_id')
+    if version:  # do not run on a fresh DB, see lp:1259975
+        logger.info("Migrating product_custom_attributes from version %s", version)
+        cr.execute("UPDATE product_template pt "
+                   "SET attribute_set_id = (SELECT pp.attribute_set_id "
+                   "                        FROM product_product pp WHERE "
+                   "                        pp.product_tmpl_id = pt.id "
+                   "                        LIMIT 1)"
+                   "WHERE pt.attribute_set_id IS NULL")
+        cr.execute('ALTER TABLE product_product DROP COLUMN attribute_set_id')


Follow ups