Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1015 (closed defect: duplicate)

Opened 11 years ago

Last modified 10 years ago

tg-admin sql create failing due to missing tables (constraint creation failure)

Reported by: mcfletch Owned by: anonymous
Priority: normal Milestone:
Component: SQLObject Version: 0.9a6
Severity: normal Keywords:
Cc:

Description

The tg-admin sql create function is failing for my schema. It appears that the code is attempting to run each table's full set of SQL statements in alphabetical order, that is, it runs all statements for a table starting with 'a', *including constraint creation*, before it starts on the tables starting with 'b'. Cases where a table is depended upon by following tables fail with

psycopg.ProgrammingError: ERROR:  relation "config_type" does not exist

where "config_type" is referenced by "config", for example.

Contrast that with tg-admin sql sql behavior (which pushes all constraint creation until after the tables have been created).

Fix is either to restructure the tg-admin sql create function to collect the constraints until the end (as with the tg-admin sql sql function) or to use a topological sort to create tables in dependency-aware order (which will only get you so far if you have circular dependencies, at which point you'll need to delay dependency setup anyway). Given the current structure I'd suggest mimicing the operation of tg-admin sql sql would be the more reasonable approach.

In the meantime, workaround is to direct tg-admin sql sql to a temporary file and use that to create the database.

SQLObject-0.8dev_r1814-py2.4.egg (with patches to fix missing tables and semicolons) TurboGears-0.9a6-py2.4.egg

Change History

comment:1 Changed 11 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to duplicate

see #1010

Note: See TracTickets for help on using tickets.