mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 19:53:55 +08:00
bd2ca8d617
This commit promotes all post_deploy migrations which existed in Discourse v3.1.0 (timestamp <= 20230405121454)
24 lines
595 B
Ruby
24 lines
595 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ReindexInvalidIndexes < ActiveRecord::Migration[7.0]
|
|
disable_ddl_transaction!
|
|
|
|
def up
|
|
invalid_index_names = DB.query_single(<<~SQL)
|
|
SELECT
|
|
pg_class.relname
|
|
FROM pg_class, pg_index, pg_namespace
|
|
WHERE pg_index.indisvalid = false
|
|
AND pg_index.indexrelid = pg_class.oid
|
|
AND pg_namespace.nspname = 'public'
|
|
AND relnamespace = pg_namespace.oid;
|
|
SQL
|
|
|
|
invalid_index_names.each { |index_name| execute "REINDEX INDEX CONCURRENTLY #{index_name}" }
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|