mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 12:28:48 +08:00
DEV: Protection for migrations that creates index concurrently take 2 (#31792)
This is a follow up to 6820622467ab3613e824f0cb6219def2a575bc1d. This commit addresses migrations that uses `remove_index` with the `if_exists: true` option to drop an existing index before creating an index using the `concurrently` option. This commit also reruns two migration which may have caused indexes to be left in an `invalid` state. ### Reviewers Note Plugin tests are failing due to https://github.com/discourse/discourse-translator/pull/251
This commit is contained in:

committed by
GitHub

parent
0ebd0a0bd5
commit
02b8aa6096
@ -1,9 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToUsersIpAddress < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :users, :ip_address, algorithm: :concurrently, name: "idx_users_ip_address"
|
||||
end
|
||||
end
|
@ -1,10 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoveUniqueConstraintFromTagUsersIndexes < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
remove_index :tag_users, name: :idx_tag_users_ix1, algorithm: :concurrently
|
||||
remove_index :tag_users, name: :idx_tag_users_ix2, algorithm: :concurrently
|
||||
remove_index :tag_users, name: :idx_tag_users_ix1, algorithm: :concurrently, if_exists: true
|
||||
remove_index :tag_users, name: :idx_tag_users_ix2, algorithm: :concurrently, if_exists: true
|
||||
|
||||
remove_index :tag_users,
|
||||
%i[user_id tag_id notification_level],
|
||||
algorithm: :concurrently,
|
||||
if_exists: true
|
||||
|
||||
remove_index :tag_users,
|
||||
%i[tag_id user_id notification_level],
|
||||
algorithm: :concurrently,
|
||||
if_exists: true
|
||||
|
||||
add_index :tag_users, %i[user_id tag_id notification_level], algorithm: :concurrently
|
||||
add_index :tag_users, %i[tag_id user_id notification_level], algorithm: :concurrently
|
19
db/migrate/20250313045010_add_index_to_users_ip_address.rb
Normal file
19
db/migrate/20250313045010_add_index_to_users_ip_address.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToUsersIpAddress < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
remove_index :users,
|
||||
:ip_address,
|
||||
algorithm: :concurrently,
|
||||
name: "idx_users_ip_address",
|
||||
if_exists: true
|
||||
|
||||
add_index :users, :ip_address, algorithm: :concurrently, name: "idx_users_ip_address"
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user