about summary refs log tree commit diff
path: root/db/migrate/20200907195410_add_index_to_users_username.rb
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-09-07 19:05:37 -0500
committerFire Demon <firedemon@creature.cafe>2020-09-08 03:37:07 -0500
commit57f74d8da4f4906fde07caa6cb05cbb824edcbc4 (patch)
treed90c6c273cab6f31b3a93d428c15903025fade51 /db/migrate/20200907195410_add_index_to_users_username.rb
parentc05f4a88260e5aeb75be6a4121e812f6669e52b4 (diff)
[Database, Models] Add indexes to users.username and User.find_by_lower_username utility methods
Diffstat (limited to 'db/migrate/20200907195410_add_index_to_users_username.rb')
-rw-r--r--db/migrate/20200907195410_add_index_to_users_username.rb8
1 files changed, 8 insertions, 0 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