about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-06-24 17:06:26 +0200
committerGitHub <noreply@github.com>2020-06-24 17:06:26 +0200
commit8f4aff9b6fe638b26b9d0bf0fe4151c2cc214d6d (patch)
tree89b283a87f3ff82b24148636594c0837aa34b322 /db/migrate
parent5d12b63e79953a7596ae473706985b774d4e51a6 (diff)
parent72d193654b9369b43090a4de2e197c21c30f3f31 (diff)
Merge pull request #1361 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb b/db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb
new file mode 100644
index 000000000..c5688681f
--- /dev/null
+++ b/db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb
@@ -0,0 +1,15 @@
+class AddFixedLowercaseIndexToAccounts < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    rename_index :accounts, 'index_accounts_on_username_and_domain_lower', 'old_index_accounts_on_username_and_domain_lower' unless index_name_exists?(:accounts, 'old_index_accounts_on_username_and_domain_lower')
+    add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true, algorithm: :concurrently
+    remove_index :accounts, name: 'old_index_accounts_on_username_and_domain_lower'
+  end
+
+  def down
+    add_index :accounts, 'lower (username), lower(domain)', name: 'old_index_accounts_on_username_and_domain_lower', unique: true, algorithm: :concurrently
+    remove_index :accounts, name: 'index_accounts_on_username_and_domain_lower'
+    rename_index :accounts, 'old_index_accounts_on_username_and_domain_lower', 'index_accounts_on_username_and_domain_lower'
+  end
+end