From b975013dfc705c8fdc92a150db7cd43ae3f46e4c Mon Sep 17 00:00:00 2001 From: ced <> Date: Thu, 14 Dec 2006 16:00:46 +0000 Subject: [PATCH] Fix migration bzr revid: ced-539157ddab355ba286593227b2223a0bd23dc2d4 --- doc/migrate/3.3.0-3.4.0/post.py | 14 ++++++++++---- doc/migrate/3.3.0-3.4.0/pre.py | 9 +++++++-- doc/migrate/3.4.0-4.0.0/README | 25 +++++++++++++++++++++++++ doc/migrate/3.4.0-4.0.0/pre.py | 5 ++++- 4 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 doc/migrate/3.4.0-4.0.0/README diff --git a/doc/migrate/3.3.0-3.4.0/post.py b/doc/migrate/3.3.0-3.4.0/post.py index cd50c61fc3b..d890b3dccba 100644 --- a/doc/migrate/3.3.0-3.4.0/post.py +++ b/doc/migrate/3.3.0-3.4.0/post.py @@ -85,9 +85,13 @@ cr.execute("select company_id from res_users where company_id is not null limit company_id = cr.fetchone()[0] # get partners - -cr.execute("select id, payment_term from res_partner where payment_term is not null") -partners = cr.dictfetchall() +cr.execute("SELECT c.relname FROM pg_class c, pg_attribute a WHERE c.relname='res_partner' AND a.attname='payment_term' AND c.oid=a.attrelid") +partners=[] +drop_payment_term=False +if cr.rowcount: + drop_payment_term=True + cr.execute("select id, payment_term from res_partner where payment_term is not null") + partners = cr.dictfetchall() # loop over them @@ -100,7 +104,9 @@ for partner in partners: ('property_payment_term', value, res_id, company_id, fields_id)) # remove the field -cr.execute("alter table res_partner drop column payment_term") +if drop_payment_term: + cr.execute("alter table res_partner drop column payment_term") +cr.execute("delete from ir_model_fields where model = 'res.partner' and name = 'payment_term'") cr.commit() diff --git a/doc/migrate/3.3.0-3.4.0/pre.py b/doc/migrate/3.3.0-3.4.0/pre.py index 5e47c519bfd..957fef586c0 100644 --- a/doc/migrate/3.3.0-3.4.0/pre.py +++ b/doc/migrate/3.3.0-3.4.0/pre.py @@ -102,9 +102,14 @@ for line in ( "alter table ir_model_fields add group_name varchar(64)", "alter table ir_model_fields add view_load boolean", "alter table ir_model_fields alter group_name set default ''", - "alter table ir_model_fields alter view_load set default False" + "alter table ir_model_fields alter view_load set default False", + "delete from ir_values where value like '%,False'", ): - cr.execute(line) + try: + cr.execute(line) + except psycopg.ProgrammingError, e: + cr.commit() + print e cr.commit() cr.close() diff --git a/doc/migrate/3.4.0-4.0.0/README b/doc/migrate/3.4.0-4.0.0/README new file mode 100644 index 00000000000..bf51831fef6 --- /dev/null +++ b/doc/migrate/3.4.0-4.0.0/README @@ -0,0 +1,25 @@ +This document describes the steps to follow to migrate from a version 3.4.0 of Tiny ERP server to a version 4.0.0 + +Warning: the migration scripts involved in this migration are only meant for +a standard Tiny ERP installation. It might not work or even break some data +if you added or modified some code to the default Tiny ERP distribution. + +To migrate a 3.4.0 server to version 4.0.0 you should: + +- stop Tiny ERP server 3.4.0 + +- backup your database + For example: pg_dump terp340 > backup340.sql + +- run the pre.py script (located in this directory) + You might need to pass it some optional arguments so that it can connect + to the database. + + For example: python pre.py -d terp340 + +- run TinyERP server 4.0.0 with "-d terp340 -u all" in the parameters + For example: ./tinyerp-server.py -d terp340 -u all + +- stop TinyERP server 4.0.0 + +- you are ready to work with the new version. diff --git a/doc/migrate/3.4.0-4.0.0/pre.py b/doc/migrate/3.4.0-4.0.0/pre.py index 22c23bbf4db..9a533cad105 100644 --- a/doc/migrate/3.4.0-4.0.0/pre.py +++ b/doc/migrate/3.4.0-4.0.0/pre.py @@ -98,8 +98,11 @@ cr.commit() # ----------------------------------------------------- # for line in ( - "ALTER TABLE ir_module_module ADD demo BOOLEAN SET DEFAULT False", + "ALTER TABLE ir_module_module ADD demo BOOLEAN DEFAULT False", + "delete from ir_values where value like '%,False'", + """UPDATE ir_ui_view set arch='' where name='ir.ui.menu.tree' and type='tree' and field_parent='child_id'""", ): cr.execute(line) +cr.commit() cr.close()