-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
'DROP INDEX' errors during database migration from 4.14.1 to 4.17 (because Postgres fails on DROP INDEX without 'IF EXISTS') #9349
Comments
based on the migration code in question, I seem to have worked around it by running this directly against the Postgres DB:
Now since the index exists, the migration was able to But I am now having the same problem on later migrations:
Please advise, what indexes should I add to workaround this? Thanks... |
I have manually added some indexes to allow the migration to drop them and recreate them, and now my instance is back online. I'll rename this issue to say that you need to use 'IF EXISTS' with a DROP INDEX for postgres compatibility. |
The |
@nijel I don't know, unfortunately (I inherited the app when it was already 4.6, and the people that used to manage it are no longer with the organization). This was a staging app, but I can see the production app is the same. Here are the indexes on the trans_unit table on the production db right now (I haven't tried to upgrade it yet from 4.14.1)
and on
Either case, can I recommend to add |
Accepting random changes to the database schema will not make the application more resilient, it will just silently accept breakage. On the It appears that something went wrong while upgrading to 4.1 where all the trgm indexes should have been created. |
@nijel , thanks for the insight about the possible 4.1 upgrade issue. I do find your response very peculiar though.
This seems a bit over an overstatement to call adding an
It will make the migration more resilient.
You are dropping an index and creating a new one. Who cares if it was already broken? You can at least keep in the forefront of your mind that you can help the users of your software by ensuring that your migration succeeds, why care about whether the index should have been there if you are only going to drop it anyway.
Finally we agree: things can go wrong. And you have a perfect opportunity to guard against such surprises that neither of us expected. Sorry that this represents a 'random change' that means you feel the need to double down on. What a shame! I guess I'll try my luck with the production upgrade and hope my workarounds work there too. Thanks anyway. |
The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.
|
Sorry, but it will never be safe to skip parts of the database migrations. Adding |
I don't think I understand what you mean.
Your migration already knows it wants to drop an existing index - all you'd be doing is ensuring you only drop if it really does exist. Nothing about adding 'IF EXISTS" to a DROP statement could cause extra things to remain. It's literally just turning a fatal error into a warning if the thing didn't exist in the first place before trying to remove it. But that's ok, I can see I can't convince you otherwise, that's why I closed it out. Thanks anyway. |
There are many other migrations that will fail if something in the database has been manually tinkered with. This is not a supported scenario. |
Describe the issue
I changed my Docker compose file from tag
4.14.1-1
to4.17.0.3
and randocker-compose pull
followed bydocker-compose up -d
to recreate the container and apply database migrations.I get an error during migration
memory.0013_reindex
ofpsycopg2.errors.UndefinedObject: index "memory_source_trgm" does not exist
.I already tried
Steps to reproduce the behavior
Install 4.14
Upgrade to 4.17
(via Docker)
Expected behavior
Database migrations should complete successfully
Screenshots
No response
Exception traceback
The text was updated successfully, but these errors were encountered: