summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-04 20:53:34 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-04 20:53:34 -0600
commite05709905db8834148c434d493344cc6f213a54b (patch)
tree2a84a74cad226f4c359fe77f25d22ec0aa7cbfa0
parentd520e6d9717d8a64e870930d08218eb30d803690 (diff)
Arregladas migraciones de usuarios y direcciones
-rw-r--r--db/migrate/20230325021349_add_unique_indexes_to_user_account_addresses.rb8
-rw-r--r--db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb4
-rw-r--r--db/schema.rb6
3 files changed, 8 insertions, 10 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
deleted file mode 100644
index d8f4d26..0000000
--- a/db/migrate/20230325021349_add_unique_indexes_to_user_account_addresses.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-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/migrate/20230325024534_add_index_spanning_users_and_addresses.rb b/db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb
index 7732728..e1d3062 100644
--- a/db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb
+++ b/db/migrate/20230325024534_add_index_spanning_users_and_addresses.rb
@@ -1,7 +1,11 @@
class AddIndexSpanningUsersAndAddresses < ActiveRecord::Migration[7.0]
def change
+ remove_foreign_key(:user_account_addresses, :user_accounts)
+ remove_foreign_key(:user_account_addresses, :addresses)
remove_index(:user_account_addresses, :user_account_id)
remove_index(:user_account_addresses, :address_id)
+ add_foreign_key(:user_account_addresses, :user_accounts)
+ add_foreign_key(:user_account_addresses, :addresses)
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)
diff --git a/db/schema.rb b/db/schema.rb
index 4020c8d..6a0f312 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -113,10 +113,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_015505) 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.bigint "user_account_id"
- t.bigint "address_id"
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"
@@ -142,5 +142,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_015505) do
add_foreign_key "product_reviews", "products"
add_foreign_key "product_reviews", "user_accounts"
add_foreign_key "products", "companies"
+ add_foreign_key "user_account_addresses", "addresses"
+ add_foreign_key "user_account_addresses", "user_accounts"
add_foreign_key "user_accounts", "carts"
end