-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
autogenerate incorrectly identifies truncated index names as new (postgres) #647
Comments
hi there - [EDIT: I am wrong here, please skip down to the later answers] this is a known issue and is in #542. there's no good automated fix for it right now, so for these long names you'll have to adjust the op.f() names manually to not include the additional characters beyond the character limit. |
let me just make sure this isn't slightly different from what's in #542 |
because in this case alembic is not comparing to sqlalchemy's own truncation which is strange |
OK this is not failing for indexes because we fixed this in #421 so what is that about not including uniques |
Mike Bayer has proposed a fix for this issue in the master branch: Adjust unique constraint names based on dialect truncation rules https://gerrit.sqlalchemy.org/1696 |
if you want to try the patch out at https://gerrit.sqlalchemy.org/changes/1696/revisions/0086c17e540adecf4719cd18f55d805e9144a2cf/patch?zip that would help to confirm this is the complete approach. |
@zzzeek : I'm still having the very same issue on 1.4.0 Not using naming conventions at all but just passing a too long name to Not sure what other information can help, let me know. Edit: Yes my SQLAlchemy version would probably help: And I'm guessing the problem will originate from there looking at #542 |
this issue has to do with SQLAlchemy's own truncation rules. If the database is doing the truncation, that's #542 and you'll need to use a matching constraint name on your end. |
A bit late to the party, is there a non-hacky solution for this? |
dont use too-long names would be your best bet, if the too-long names are in production DB already, hardcode them in your migraitons until you can change them |
I have a postgres database using naming conventions for automated naming of constraints following the naming scheme:
If I generate my database with a create_all I get my constraint named
uq_vrm_positive_refdes_positive_net_negative_refdes_neg_fe9c
as expected.However when I subsequently run:
alembic revision --autogenerate -m "some message"
I get the following output:
The generated upgrade contains the lines:
the migration then fails because the op.f results in the correct naming scheme of
uq_vrm_positive_refdes_positive_net_negative_refdes_neg_fe9c
and postgres errors out because the constraint already existsdescribing the table in postgres I see:
sqlalchemy version: 1.3.13
alembic version: 1.3.3
postgres server: 12.1
psycopg2 version: 2.8.4
The text was updated successfully, but these errors were encountered: