-
-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postgresql serial column detection might fail #1565
Comments
Hi, It seems like a bug, but I'm proposing to close as won't fix. The reason is that they table definition that you have are highly unlikely, since it doesn't make much sense adding a fk on an auto-incrementing column. Thoughts @zzzeek ? |
Actually, it can happen on a table with serial column and being referenced by another table(doesn't matter adding foreign key on which column), just like: CREATE SCHEMA test;
CREATE TABLE test.account1(short_id SERIAL PRIMARY KEY, id uuid unique);
CREATE TABLE test.account2(short_id SERIAL PRIMARY KEY, id uuid unique REFERENCES test.account1(id));
ALTER TABLE test.account1 ADD FOREIGN KEY (id) REFERENCES test.account2(id); -- not necessary Besides two tables reference each other just make it easier to reproduce, it's not necessary. |
alembic/alembic/autogenerate/compare.py Lines 204 to 219 in 431fd07
Looks like when reflecting table, the referenced table will be reflected too, since the default value of another similar issue: #1454 |
Describe the bug
There is a probability that serial column was not detected.
This can happen when the table is referenced by another table.
Expected behavior
The result of autogererate should't contain server default for column id.
To Reproduce
Error
It will produce two outputs and the first one is incorrect.
Versions.
Additional context
If table is not fererenced by other table, the result is always correct.
If I make both tables reference each other, the first table in autogenerate is alway incorrect.
I guess the listen hook migth fail with foreign keys, not sure since havn't dig into code much.
Have a nice day!
The text was updated successfully, but these errors were encountered: