Issue 5027

Title
Try create new PSQL schema when exist
Priority
bug
Status
invalid
Nosy list
ced, resteve
Assigned to
resteve
Keywords
review

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

Messages

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.

Thanks
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 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
History
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