Suppose I have the following model:
foo = StringCol()
b = ForeignKey("B")
bar = StringCol()
If I now let sqlobject-admin create the tables for me,
the order in with these are created is not defined.
If table A is created before table B, PostgreSQL will fail:
CREATE TABLE a (
id SERIAL PRIMARY KEY,
b_id INT, CONSTRAINT b_id_exists FOREIGN KEY (b_id)
REFERENCES b (id)
Fails with "Relation >b< does not exist"
So, I've patched manager/command.py to create tables in
the order of classes with fewest foreign keys created
This might not catch all cases, but it "works for me(TM)"
Patch is attached
Log in to post a comment.