Skip to content
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

Fix migration script not being able to run if it fails midway #16312

Merged
merged 4 commits into from
Jun 2, 2021

Conversation

ClearlyClaire
Copy link
Contributor

Partially addresses #16273, similar to #15361

More generally, we should be more careful when writing migration scripts with disable_ddl_transaction!.

safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower ON tags (lower(name))' }
rescue ActiveRecord::StatementInvalid
remove_index :tags, name: 'index_tags_on_name_lower'
raise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this raise a StatementInvalid error but others are raising CorruptionError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not pointing at the documentation because it's a much older migration which is not handled by the maintenance script. It's very unlikely people run into issues running this migration, but I wanted to add the remove_index to at least ensure the effects of the migration would be reverted if it ran into an issue.

@Gargron Gargron merged commit 11d3c06 into mastodon:main Jun 2, 2021
GensouSakuya pushed a commit to GensouSakuya/mastodon that referenced this pull request Jun 3, 2021
…on#16312)

* Fix migration script not being able to run if it fails midway

* Fix old migration script

* Fix old migration script

* Refactor CorruptionError
ClearlyClaire added a commit to ClearlyClaire/mastodon that referenced this pull request Jan 28, 2022
…on#16312)

* Fix migration script not being able to run if it fails midway

* Fix old migration script

* Fix old migration script

* Refactor CorruptionError
chrisguida pushed a commit to Start9Labs/mastodon that referenced this pull request Feb 26, 2022
…on#16312)

* Fix migration script not being able to run if it fails midway

* Fix old migration script

* Fix old migration script

* Refactor CorruptionError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants