I am taking a look at TurboGears and following through the getting
started guide. I have found that running "tg-admin sql create" fails
with models containing foreign keys because the create table statements
are issued in the wrong order. I am using postgresql.
Here's an example model:
class Site(SQLObject):
name = StringCol(length=25)
members = MultipleJoin('Member')
class Member(SQLObject):
site = ForeignKey('Site', unique=True)
username = StringCol(length=25)
Running "tg-admin sql sql" outputs the following:
CREATE TABLE member (
id SERIAL PRIMARY KEY,
site_id INT UNIQUE, CONSTRAINT site_id_exists FOREIGN KEY (site_id)
REFERENCES site (id) ,
username VARCHAR(25)
);
CREATE TABLE site (
id SERIAL PRIMARY KEY,
name VARCHAR(25)
);
And "tg-admin sql create" fails on the CREATE TABLE member statement as
the site table does not exist yet. Is this a known limitation, or is
there some way around this?
Kind Regards,
Sean Cazzell
But with current version, several workaround exists:
Check my diary, you will see which solution I'm using, and you'll have
a link to an another solution.
http://projectsmgt.opensource4you.org/ProjectsMgt/wiki/MyDiary
tg-admin sql create --class=Site
tg-admin sql create --class=Memeber