Issue 5027

Try create new PSQL schema when exist
Nosy list
ced, resteve
Assigned to

Created on 2015-10-07.13:36:04 by resteve, last changed 84 months ago by ced.


Author: [hidden] (resteve)
Date: 2015-10-07.15:04:44
> Your table and field name are too long and so the foreign is truncated

Ok. I try to reduce table name and fix it.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2015-10-07.14:46:16
Indeed r 2d0e4205e02a just shows more explicitly that your code was not working.
Your table and field name are too long and so the foreign is truncated (and before it was truncated silently and you will have a new foreign key after each update).
See issue4774 for the discussion about table name length.
Author: [hidden] (resteve)
Date: 2015-10-07.13:36:02
Since c 2d0e4205e02a or issue4924

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
Traceback (most recent call last):
  File "./trytond/bin/trytond", line 80, in <module>
  File "/home/resteve/virtualenv/try37/trytond/trytond/", line 112, in run
    Pool(db_name).init(update=self.options.update, lang=lang)
  File "/home/resteve/virtualenv/try37/trytond/trytond/", line 155, in init
  File "/home/resteve/virtualenv/try37/trytond/trytond/modules/", line 427, in load_modules
  File "/home/resteve/virtualenv/try37/trytond/trytond/modules/", line 394, in _load_modules
    load_module_graph(graph, pool, update, lang)
  File "/home/resteve/virtualenv/try37/trytond/trytond/modules/", line 234, in load_module_graph
  File "/home/resteve/virtualenv/try37/trytond/trytond/model/", line 195, in __register__
    table.add_fk(field_name, ref, field.ondelete)
  File "/home/resteve/virtualenv/try37/trytond/trytond/backend/postgresql/", line 322, in add_fk
    'ON DELETE ' + on_delete)
  File "/home/resteve/virtualenv/try37/trytond/trytond/backend/postgresql/", 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
    "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.

Date User Action Args
2015-10-07 15:31:06cedsetstatus: chatting -> invalid
2015-10-07 15:04:45restevesetstatus: invalid -> chatting
messages: + msg22706
2015-10-07 14:46:16cedsetstatus: chatting -> invalid
nosy: + ced
messages: + msg22705
2015-10-07 13:36:05restevecreate