From d2df5b287235711f1af5e096eb57c69cd0f0a351 Mon Sep 17 00:00:00 2001 From: Adrien Poly Date: Mon, 25 Mar 2024 20:59:49 +0100 Subject: [PATCH] add uniq index for users email to ensure uniqueness (#567) --- db/migrate/20240325064211_add_uniq_index_to_users_email.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20240325064211_add_uniq_index_to_users_email.rb diff --git a/db/migrate/20240325064211_add_uniq_index_to_users_email.rb b/db/migrate/20240325064211_add_uniq_index_to_users_email.rb new file mode 100644 index 00000000..923e6848 --- /dev/null +++ b/db/migrate/20240325064211_add_uniq_index_to_users_email.rb @@ -0,0 +1,5 @@ +class AddUniqIndexToUsersEmail < ActiveRecord::Migration[7.2] + def change + add_index :users, :email, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 459eaaf2..a3110426 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[7.2].define(version: 2024_03_19_154732) do +ActiveRecord::Schema[7.2].define(version: 2024_03_25_064211) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -232,6 +232,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_03_19_154732) do t.string "password_digest" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["email"], name: "index_users_on_email", unique: true t.index ["family_id"], name: "index_users_on_family_id" end