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

[4.2.0 Beta 1/2] 20230803082451 AddUniqueIndexOnPreviewCardsStatuses Migration Fails, table already exists #2387

Closed
zerojay opened this issue Aug 28, 2023 · 10 comments
Labels

Comments

@zerojay
Copy link

zerojay commented Aug 28, 2023

Steps to reproduce the problem

  1. Upgraded Docker 4.1.6 to 4.2.0-beta1 or beta 2
  2. See pending database migrations listed in the Admin section.
  3. Attempt to run database migrations by running RAILS_ENV=production bundle exec rails db:migrate

Expected behaviour

Database migrations should succeed successfully.

Actual behaviour

Database migrations fail due to PG::DuplicateTable: ERROR: relation "preview_cards_statuses_pkey" already exists

Detailed description

It appears that database migrations fail due to a duplicate table already existing in Postgres database. Potentially related to mastodon#26446.

Mastodon instance

toot.zerojay.com

Mastodon version

4.2.0-beta2+glitch_0827_efb1888

Technical details

All software versions (ruby and such) are those provided by the prebuilt glitch-soc docker images and have not been changed by me before deploying.

Log output:

mastodon@mastodon-web:~/bin$ RAILS_ENV=production bundle exec rails db:migrate
(in /opt/mastodon)
I, [2023-08-28T09:43:15.752428 #412]  INFO -- : Migrating to AddUniqueIndexOnPreviewCardsStatuses (20230803082451)
== 20230803082451 AddUniqueIndexOnPreviewCardsStatuses: migrating =============
[strong_migrations] DANGER: No lock timeout set
-- add_index(:preview_cards_statuses, [:status_id, :preview_card_id], {:name=>:preview_cards_statuses_pkey, :algorithm=>:concurrently, :unique=>true})
rails aborted!
StandardError: An error has occurred, all later migrations canceled:

**PG::DuplicateTable: ERROR:  relation "preview_cards_statuses_pkey" already exists**
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `load'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'

Caused by:
ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR:  relation "preview_cards_statuses_pkey" already exists
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `load'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'

Caused by:
PG::DuplicateTable: ERROR:  relation "preview_cards_statuses_pkey" already exists
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `load'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:58:in `kernel_load'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli/exec.rb:23:in `run'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:492:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:34:in `dispatch'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/cli.rb:28:in `start'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:45:in `block in <top (required)>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bundler-2.4.13/exe/bundle:33:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

@zerojay zerojay added the bug label Aug 28, 2023
@ClearlyClaire
Copy link

That is weird. Have you ever manually added an index? Can you open a PostgreSQL shell and type \d+ preview_cards_statuses? Then, if it lists more than one index, do DROP INDEX preview_cards_statuses_pkey and rerun the migration?

@zerojay
Copy link
Author

zerojay commented Aug 31, 2023

Sorry for the late reply.

bash-5.1# psql -d mastodon_production -U mastodon
psql (9.6.24)
Type "help" for help.

mastodon_production=# \d+ preview_cards_statuses
                    Table "public.preview_cards_statuses"
     Column      |  Type  | Modifiers | Storage | Stats target | Description
-----------------+--------+-----------+---------+--------------+-------------
 preview_card_id | bigint | not null  | plain   |              |
 status_id       | bigint | not null  | plain   |              |
Indexes:
    "preview_cards_statuses_pkey" UNIQUE, btree (status_id, preview_card_id) INVALID
    "index_preview_cards_statuses_on_status_id_and_preview_card_id" btree (status_id, preview_card_id)

Using drop index as you requested doesn't seem to have helped as I get the same error when I run the migration again.

@ClearlyClaire
Copy link

Can you drop the index again, and run the migrations again? Please share the first error message from the migration, I suspect you ran it multiple times and it resulted in different error messages!

@zerojay
Copy link
Author

zerojay commented Aug 31, 2023

Attempt #2:

bash-5.1# psql -d mastodon_production -U mastodon
psql (9.6.24)
Type "help" for help.

mastodon_production=# \d+ preview_cards_statuses
                    Table "public.preview_cards_statuses"
     Column      |  Type  | Modifiers | Storage | Stats target | Description
-----------------+--------+-----------+---------+--------------+-------------
 preview_card_id | bigint | not null  | plain   |              |
 status_id       | bigint | not null  | plain   |              |
Indexes:
    "preview_cards_statuses_pkey" UNIQUE, btree (status_id, preview_card_id) INVALID
    "index_preview_cards_statuses_on_status_id_and_preview_card_id" btree (status_id, preview_card_id)

mastodon_production=# DROP INDEX preview_cards_statuses_pkey
mastodon_production-#

mastodon@mastodon-web:~$ RAILS_ENV=production bundle exec rails db:migrate
I, [2023-08-31T04:56:40.020302 #5904]  INFO -- : Migrating to AddUniqueIndexOnPreviewCardsStatuses (20230803082451)
== 20230803082451 AddUniqueIndexOnPreviewCardsStatuses: migrating =============
[strong_migrations] DANGER: No lock timeout set
-- add_index(:preview_cards_statuses, [:status_id, :preview_card_id], {:name=>:preview_cards_statuses_pkey, :algorithm=>:concurrently, :unique=>true})
rails aborted!
StandardError: An error has occurred, all later migrations canceled:

PG::DuplicateTable: ERROR:  relation "preview_cards_statuses_pkey" already exists
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

Caused by:
ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR:  relation "preview_cards_statuses_pkey" already exists
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

Caused by:
PG::DuplicateTable: ERROR:  relation "preview_cards_statuses_pkey" already exists
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Should I be running these with Mastodon's docker instances stopped, perhaps? I believe they were stopped when I first hit this issue. This second run was with it still running. Also, to answer one of your original questions, no, I did not make any manual changes to the database at all as I am unfamiliar with postgres to the point where I had to look up how to log into the database.

@ClearlyClaire
Copy link

Oh, in SQL, type DROP INDEX preview_cards_statuses_pkey; with a final ;

@zerojay
Copy link
Author

zerojay commented Aug 31, 2023

Okay, dropping the table appeared to succeed this time. Here's the output from the migration attempt afterwards. In case it matters, here's the postgres container I'm using: postgres:9.6-alpine

mastodon@mastodon-web:~$ RAILS_ENV=production bundle exec rails db:migrate
I, [2023-08-31T05:16:24.859119 #6230]  INFO -- : Migrating to AddUniqueIndexOnPreviewCardsStatuses (20230803082451)
== 20230803082451 AddUniqueIndexOnPreviewCardsStatuses: migrating =============
[strong_migrations] DANGER: No lock timeout set
-- add_index(:preview_cards_statuses, [:status_id, :preview_card_id], {:name=>:preview_cards_statuses_pkey, :algorithm=>:concurrently, :unique=>true})
-- select_all("SELECT status_id FROM preview_cards_statuses GROUP BY status_id HAVING count(*) > 1;")
   -> 66.2694s
-- execute("DELETE FROM preview_cards_statuses p WHERE p.status_id IN (110944420085668033, 110949408602908182, 110951535292627658, 110951803348129983, 110955176179292257, 110955674127457883, 110956005874402489, 110957562236483875, 110959521080779126, 110960487965913673, 110962768232135589, 110965528391399932, 110966625780339724, 110968501187707672, 110972656610556297, 110977537513397191, 110978067988801821, 110979843898043685, 110980624339002370) AND p.ctid NOT IN (SELECT q.ctid FROM preview_cards_statuses q WHERE q.status_id = p.status_id LIMIT 1)")
   -> 0.1148s
-- execute("REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey")
rails aborted!
StandardError: An error has occurred, all later migrations canceled:

PG::SyntaxError: ERROR:  syntax error at or near "CONCURRENTLY"
LINE 1: REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey
                      ^
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:21:in `block in deduplicate_and_reindex!'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:23:in `block in safety_assured'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:19:in `safety_assured'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:22:in `safety_assured'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:21:in `deduplicate_and_reindex!'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:9:in `rescue in up'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:6:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

Caused by:
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near "CONCURRENTLY"
LINE 1: REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey
                      ^
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:21:in `block in deduplicate_and_reindex!'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:23:in `block in safety_assured'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:19:in `safety_assured'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:22:in `safety_assured'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:21:in `deduplicate_and_reindex!'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:9:in `rescue in up'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:6:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

Caused by:
PG::SyntaxError: ERROR:  syntax error at or near "CONCURRENTLY"
LINE 1: REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey
                      ^
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:21:in `block in deduplicate_and_reindex!'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:23:in `block in safety_assured'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:19:in `safety_assured'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:22:in `safety_assured'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:21:in `deduplicate_and_reindex!'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:9:in `rescue in up'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:6:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

Caused by:
ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  could not create unique index "preview_cards_statuses_pkey"
DETAIL:  Key (status_id, preview_card_id)=(110980624339002370, 1785802) is duplicated.
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

Caused by:
PG::UniqueViolation: ERROR:  could not create unique index "preview_cards_statuses_pkey"
DETAIL:  Key (status_id, preview_card_id)=(110980624339002370, 1785802) is duplicated.
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `exec'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:48:in `block (2 levels) in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:47:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:752:in `block in log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.7.2/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract_adapter.rb:743:in `log'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:46:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql/schema_statements.rb:448:in `add_index'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:932:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `block in say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:900:in `say_with_time'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:921:in `method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:16:in `block in method_missing'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/checker.rb:322:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:15:in `method_missing'
/opt/mastodon/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb:7:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `public_send'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:873:in `exec_migration'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:853:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:852:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/migration.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1046:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1413:in `ddl_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1282:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `block in migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/strategy.rb:60:in `wrap'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy.rb:154:in `strategy'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/chewy-7.3.3/lib/chewy/railtie.rb:28:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1117:in `up'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/migration.rb:1092:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/strong_migrations-0.8.0/lib/strong_migrations/database_tasks.rb:5:in `migrate'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/command.rb:51:in `invoke'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/railties-7.0.7.2/lib/rails/commands.rb:18:in `<main>'
/opt/mastodon/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

@ClearlyClaire
Copy link

Thanks, that new trace is very helpful! This migration unfortunately uses something that is only available from PostgreSQL 12. I will patch it to be compatible with earlier versions of PostgreSQL.

@ClearlyClaire
Copy link

can you drop the index again, and retry with this patch?

diff --git a/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb b/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb
index c35ad80028..3e9ab134b7 100644
--- a/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb
+++ b/db/post_migrate/20230803082451_add_unique_index_on_preview_cards_statuses.rb
@@ -15,10 +15,22 @@ class AddUniqueIndexOnPreviewCardsStatuses < ActiveRecord::Migration[6.1]
 
   private
 
+  def supports_concurrent_reindex?
+    @supports_concurrent_reindex ||= begin
+      version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i
+      version >= 12_000
+    end
+  end
+
   def deduplicate_and_reindex!
     deduplicate_preview_cards!
 
-    safety_assured { execute 'REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey' }
+    if supports_concurrent_reindex?
+      safety_assured { execute 'REINDEX INDEX CONCURRENTLY preview_cards_statuses_pkey' }
+    else
+      remove_index :preview_cards_statuses, name: :preview_cards_statuses_pkey
+      add_index :preview_cards_statuses, [:status_id, :preview_card_id], name: :preview_cards_statuses_pkey, algorithm: :concurrently, unique: true
+    end
   rescue ActiveRecord::RecordNotUnique
     retry
   end

@zerojay
Copy link
Author

zerojay commented Sep 1, 2023

Sorry, I'm running the docker images so I'm unable to apply the patch directly. I may just attempt to upgrade my postgres server to v12 or higher and see how it goes in the meantime. Thank you for the help.

@zerojay
Copy link
Author

zerojay commented Sep 5, 2023

The migrating to postgres 12 worked fine for me with the latest glitch docker image and the migrations were successful.

@zerojay zerojay closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants