Try create new PSQL schema when exist
Since c 2d0e4205e02a or #4924 (closed)
When reupdate a module, try to create new schema and exist.
5269 140425098422080 [2015-10-07 11:24:52,971] INFO trytond.modules product_review:register product.configurations.product.review.type
Traceback (most recent call last):
File "./trytond/bin/trytond", line 80, in <module>
server.TrytonServer(options).run()
File "/home/resteve/virtualenv/try37/trytond/trytond/server.py", line 112, in run
Pool(db_name).init(update=self.options.update, lang=lang)
File "/home/resteve/virtualenv/try37/trytond/trytond/pool.py", line 155, in init
lang=lang)
File "/home/resteve/virtualenv/try37/trytond/trytond/modules/__init__.py", line 427, in load_modules
_load_modules()
File "/home/resteve/virtualenv/try37/trytond/trytond/modules/__init__.py", line 394, in _load_modules
load_module_graph(graph, pool, update, lang)
File "/home/resteve/virtualenv/try37/trytond/trytond/modules/__init__.py", line 234, in load_module_graph
cls.__register__(module)
File "/home/resteve/virtualenv/try37/trytond/trytond/model/modelsql.py", line 195, in __register__
table.add_fk(field_name, ref, field.ondelete)
File "/home/resteve/virtualenv/try37/trytond/trytond/backend/postgresql/table.py", line 322, in add_fk
'ON DELETE ' + on_delete)
File "/home/resteve/virtualenv/try37/trytond/trytond/backend/postgresql/database.py", line 284, in execute
return self.cursor.execute(sql)
psycopg2.ProgrammingError: constraint "product_configuration_product_review_type_rel_configuration_fke" for relation "product_configuration_product_review_type_rel" already exists
And SQL table structure:
try37review=# \d product_configuration_product_review_type_rel
Table "public.product_configuration_product_review_type_rel"
Column | Type | Modifiers
---------------+--------------------------------+--------------------------------------------------------------------------------------------
id | integer | not null default nextval('product_configuration_product_review_type_rel_id_seq'::regclass)
create_uid | integer |
create_date | timestamp(6) without time zone |
write_uid | integer |
write_date | timestamp(6) without time zone |
review_type | integer | not null
configuration | integer | not null
Indexes:
"product_configuration_product_review_type_rel_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"product_configuration_product_review_type_rel_configuration_fke" FOREIGN KEY (configuration) REFERENCES product_configuration(id) ON DELETE CASCADE
"product_configuration_product_review_type_rel_review_type_fkey" FOREIGN KEY (review_type) REFERENCES product_review_type(id) ON DELETE CASCADE
When try to reupload module, "self.cursor.rowcount" is "0" in (1) and add to True.
I think review20461002 fix it.
(1) http://hg.tryton.org/trytond/file/7e29cd647fad/trytond/backend/postgresql/table.py#l312