about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200907195410_add_index_to_users_username.rb8
-rw-r--r--db/schema.rb4
2 files changed, 11 insertions, 1 deletions
diff --git a/db/migrate/20200907195410_add_index_to_users_username.rb b/db/migrate/20200907195410_add_index_to_users_username.rb
new file mode 100644
index 000000000..06452e0dd
--- /dev/null
+++ b/db/migrate/20200907195410_add_index_to_users_username.rb
@@ -0,0 +1,8 @@
+class AddIndexToUsersUsername < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :users, :username, unique: true, algorithm: :concurrently
+    add_index :users, 'lower(username)', unique: true, algorithm: :concurrently, name: 'index_on_users_username_lowercase'
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 87cca4ea1..fbcf8e636 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_09_04_201028) do
+ActiveRecord::Schema.define(version: 2020_09_07_195410) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -990,12 +990,14 @@ ActiveRecord::Schema.define(version: 2020_09_04_201028) do
     t.string "username"
     t.string "kobold"
     t.string "webauthn_id"
+    t.index "lower((username)::text)", name: "index_on_users_username_lowercase", unique: true
     t.index ["account_id"], name: "index_users_on_account_id"
     t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
     t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
     t.index ["email"], name: "index_users_on_email", unique: true
     t.index ["remember_token"], name: "index_users_on_remember_token", unique: true
     t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+    t.index ["username"], name: "index_users_on_username", unique: true
   end
 
   create_table "web_push_subscriptions", force: :cascade do |t|