summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-24 20:47:26 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-24 20:47:26 -0600
commitdb54484188304747af8e6c8299f1ccb5b3e1095f (patch)
tree1ba7b105e9bf8d1e13a581edc5f5a2bc451e42a1 /db
parentf5f27394fd4c68995949f43edca41d30d30a45aa (diff)
Añade índice a los dos campos del join table
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb9
-rw-r--r--db/schema.rb7
2 files changed, 13 insertions, 3 deletions
diff --git a/db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb b/db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb
new file mode 100644
index 0000000..7732728
--- /dev/null
+++ b/db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb
@@ -0,0 +1,9 @@
+class AddIndexSpanningUsersAndAddresses < 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)
+ add_index(:user_account_addresses, :address_id)
+ add_index(:user_account_addresses, [:address_id, :user_account_id], unique: true)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5a35c86..26cf4a6 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_25_021349) do
+ActiveRecord::Schema[7.0].define(version: 2023_03_25_024534) 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
@@ -75,8 +75,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_25_021349) do
t.datetime "updated_at", null: false
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
+ t.index ["address_id", "user_account_id"], name: "index_user_account_addresses_on_address_id_and_user_account_id", unique: true
+ 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"
end
create_table "user_accounts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|