summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/migrate/20230325021349_add_unique_indexes_to_user_account_addresses.rb8
-rw-r--r--db/schema.rb12
2 files changed, 13 insertions, 7 deletions
diff --git a/db/migrate/20230325021349_add_unique_indexes_to_user_account_addresses.rb b/db/migrate/20230325021349_add_unique_indexes_to_user_account_addresses.rb
new file mode 100644
index 0000000..d8f4d26
--- /dev/null
+++ b/db/migrate/20230325021349_add_unique_indexes_to_user_account_addresses.rb
@@ -0,0 +1,8 @@
+class AddUniqueIndexesToUserAccountAddresses < ActiveRecord::Migration[7.0]
+ def change
+ remove_index(:user_account_addresses, :user_account_id)
+ remove_index(:user_account_addresses, :address_id)
+ add_index(:user_account_addresses, :user_account_id, unique: true)
+ add_index(:user_account_addresses, :address_id, unique: true)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index eda3bd5..5a35c86 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.0].define(version: 2023_03_22_234849) do
+ActiveRecord::Schema[7.0].define(version: 2023_03_25_021349) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -71,12 +71,12 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_22_234849) do
end
create_table "user_account_addresses", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
- t.bigint "user_account_id", null: false
- t.bigint "address_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.index ["address_id"], name: "index_user_account_addresses_on_address_id"
- t.index ["user_account_id"], name: "index_user_account_addresses_on_user_account_id"
+ t.bigint "user_account_id"
+ t.bigint "address_id"
+ t.index ["address_id"], name: "index_user_account_addresses_on_address_id", unique: true
+ t.index ["user_account_id"], name: "index_user_account_addresses_on_user_account_id", unique: true
end
create_table "user_accounts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
@@ -93,6 +93,4 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_22_234849) do
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "products", "companies"
- add_foreign_key "user_account_addresses", "addresses"
- add_foreign_key "user_account_addresses", "user_accounts"
end