about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-06-24 15:33:41 +0200
committerThibaut Girka <thib@sitedethib.com>2020-06-24 15:33:41 +0200
commitaae60a2366d6dadbcc4a0197d4dd17afc931c8a0 (patch)
tree0bbbc278809d9990365a2d79abeaf02891990d51 /db
parent5d12b63e79953a7596ae473706985b774d4e51a6 (diff)
parentbb9ca8a587ee5a3ec8778e72828aca0ba8871327 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/concerns/sign_in_token_authentication_concern.rb`:
  Conflict due to glitch-soc's theming system.
  Ported upstream changes.
- `app/controllers/concerns/two_factor_authentication_concern.rb`:
  Conflict due to glitch-soc's theming system.
  Ported upstream changes.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb15
-rw-r--r--db/schema.rb4
2 files changed, 17 insertions, 2 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
diff --git a/db/schema.rb b/db/schema.rb
index c1b6ffa81..2f3660dd5 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2020_06_08_113046) do
+ActiveRecord::Schema.define(version: 2020_06_20_164023) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -176,7 +176,7 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.integer "header_storage_schema_version"
     t.string "devices_url"
     t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
-    t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
+    t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
     t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
     t.index ["uri"], name: "index_accounts_on_uri"
     t.index ["url"], name: "index_accounts_on_url"