Fix bad move from previous commit and now move the right portion from res_currency_rate
authorced <>
Thu, 16 Aug 2007 14:10:08 +0000 (14:10 +0000)
committerced <>
Thu, 16 Aug 2007 14:10:08 +0000 (14:10 +0000)
bzr revid: ced-09d632ef5348eed56ee7561f747d2b54a2209cab

doc/migrate/4.0.0-4.2.0/pre-tiny.py
doc/migrate/4.0.0-4.2.0/pre.py

index 0cd3788..cc07722 100644 (file)
@@ -73,23 +73,6 @@ password = hasattr(options, 'db_password') and "password=%s" % options.db_passwo
 db = psycopg.connect('%s %s %s %s %s' % (host, port, name, user, password), serialize=0)
 cr = db.cursor()
 
-# ------------------------ #
-# change currency rounding #
-# ------------------------ #
-
-cr.execute("""SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size FROM pg_class c,pg_attribute a,pg_type t WHERE c.relname='res_currency' AND a.attname='rounding' AND c.oid=a.attrelid AND a.atttypid=t.oid""")
-res = cr.dictfetchall()
-if res[0]['typname'] != 'numeric':
-       for line in (
-               "ALTER TABLE res_currency RENAME rounding TO rounding_bak",
-               "ALTER TABLE res_currency ADD rounding NUMERIC(12,6)",
-               "UPDATE res_currency SET rounding = power(10, - rounding_bak)",
-               "ALTER TABLE res_currency DROP rounding_bak",
-               ):
-               cr.execute(line)
-cr.commit()
-
-
 # fix country
 
 
@@ -182,3 +165,16 @@ cr.execute('SELECT tablename FROM pg_tables WHERE tablename = \'subscription_sub
 if cr.fetchall():
        cr.execute('DROP TABLE subscription_subscription_history')
 cr.commit()
+
+# -------------------- #
+# Change currency rate #
+# -------------------- #
+
+cr.execute('SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname = \'res_currency_rate\' AND a.attname = \'rate_old\' AND c.oid = a.attrelid')
+if not cr.fetchall():
+       cr.execute('ALTER TABLE res_currency_rate ADD rate_old NUMERIC(12,6)')
+       cr.execute('UPDATE res_currency_rate SET rate_old = rate')
+       cr.execute('UPDATE res_currency_rate SET rate = (1 / rate_old)')
+cr.commit()
+
+cr.close
index 3eaf546..b5dc76c 100644 (file)
@@ -73,6 +73,22 @@ password = hasattr(options, 'db_password') and "password=%s" % options.db_passwo
 db = psycopg.connect('%s %s %s %s %s' % (host, port, name, user, password), serialize=0)
 cr = db.cursor()
 
+# ------------------------ #
+# change currency rounding #
+# ------------------------ #
+
+cr.execute("""SELECT c.relname,a.attname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,t.typname,CASE WHEN a.attlen=-1 THEN a.atttypmod-4 ELSE a.attlen END as size FROM pg_class c,pg_attribute a,pg_type t WHERE c.relname='res_currency' AND a.attname='rounding' AND c.oid=a.attrelid AND a.atttypid=t.oid""")
+res = cr.dictfetchall()
+if res[0]['typname'] != 'numeric':
+       for line in (
+               "ALTER TABLE res_currency RENAME rounding TO rounding_bak",
+               "ALTER TABLE res_currency ADD rounding NUMERIC(12,6)",
+               "UPDATE res_currency SET rounding = power(10, - rounding_bak)",
+               "ALTER TABLE res_currency DROP rounding_bak",
+               ):
+               cr.execute(line)
+cr.commit()
+
 # ----------------------------- #
 # drop constraint on ir_ui_view #
 # ----------------------------- #
@@ -155,15 +171,4 @@ if not cr.fetchall():
        cr.execute('INSERT INTO ir_values (name, key, model, meta, key2, object, value) VALUES (\'tz\', \'meta\', \'res.users\', %s, \'tz\', %s, %s)', (meta,False, value))
 cr.commit()
 
-# -------------------- #
-# Change currency rate #
-# -------------------- #
-
-cr.execute('SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname = \'res_currency_rate\' AND a.attname = \'rate_old\' AND c.oid = a.attrelid')
-if not cr.fetchall():
-       cr.execute('ALTER TABLE res_currency_rate ADD rate_old NUMERIC(12,6)')
-       cr.execute('UPDATE res_currency_rate SET rate_old = rate')
-       cr.execute('UPDATE res_currency_rate SET rate = (1 / rate_old)')
-cr.commit()
-
 cr.close