From 4052329ca49b05b14baceee17dd8bd4607c9c9a1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 10 Mar 2020 17:44:32 -0500 Subject: [PATCH] Add unique_email field --- app/models/user.rb | 1 + db/migrate/20200310223351_add_unique_email_to_users.rb | 5 +++++ .../20200310224203_add_index_unique_email_on_users.rb | 7 +++++++ db/schema.rb | 4 +++- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200310223351_add_unique_email_to_users.rb create mode 100644 db/migrate/20200310224203_add_index_unique_email_on_users.rb diff --git a/app/models/user.rb b/app/models/user.rb index 6eadbb2b..ed081c90 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,6 +39,7 @@ # created_by_application_id :bigint(8) # approved :boolean default(TRUE), not null # last_read_notification :bigint(8) +# unique_email :string # class User < ApplicationRecord diff --git a/db/migrate/20200310223351_add_unique_email_to_users.rb b/db/migrate/20200310223351_add_unique_email_to_users.rb new file mode 100644 index 00000000..45b6ffa8 --- /dev/null +++ b/db/migrate/20200310223351_add_unique_email_to_users.rb @@ -0,0 +1,5 @@ +class AddUniqueEmailToUsers < ActiveRecord::Migration[5.2] + def change + add_column :users, :unique_email, :string + end +end diff --git a/db/migrate/20200310224203_add_index_unique_email_on_users.rb b/db/migrate/20200310224203_add_index_unique_email_on_users.rb new file mode 100644 index 00000000..a7b5216d --- /dev/null +++ b/db/migrate/20200310224203_add_index_unique_email_on_users.rb @@ -0,0 +1,7 @@ +class AddIndexUniqueEmailOnUsers < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def change + add_index :users, :unique_email, algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index 3d8c22ab..2570abba 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: 2019_12_02_004114) do +ActiveRecord::Schema.define(version: 2020_03_10_224203) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -824,11 +824,13 @@ ActiveRecord::Schema.define(version: 2019_12_02_004114) do t.bigint "created_by_application_id" t.boolean "approved", default: true, null: false t.bigint "last_read_notification" + t.string "unique_email" 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 ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + t.index ["unique_email"], name: "index_users_on_unique_email" end create_table "web_push_subscriptions", force: :cascade do |t|