Improve various queries against account domains (#25126)
parent
e58c36d308
commit
1d588d58f1
7 changed files with 42 additions and 3 deletions
@ -0,0 +1,9 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class AddIndexAccountsOnDomainAndId < ActiveRecord::Migration[6.1] |
||||
disable_ddl_transaction! |
||||
|
||||
def change |
||||
add_index :accounts, [:domain, :id], name: :index_accounts_on_domain_and_id, algorithm: :concurrently |
||||
end |
||||
end |
@ -0,0 +1,13 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class FixAccountDomainCasing < ActiveRecord::Migration[6.1] |
||||
disable_ddl_transaction! |
||||
|
||||
def up |
||||
safety_assured do |
||||
execute 'UPDATE accounts SET domain = lower(domain) WHERE domain IS NOT NULL AND domain != lower(domain)' |
||||
end |
||||
end |
||||
|
||||
def down; end |
||||
end |
@ -0,0 +1,9 @@ |
||||
# frozen_string_literal: true |
||||
|
||||
class AddIndexInstancesOnReverseDomain < ActiveRecord::Migration[6.1] |
||||
disable_ddl_transaction! |
||||
|
||||
def change |
||||
add_index :instances, "reverse('.' || domain), domain", name: :index_instances_on_reverse_domain, algorithm: :concurrently |
||||
end |
||||
end |
Loading…
Reference in new issue