summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-04 20:45:40 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-04 20:45:40 -0600
commit7dd7989bba156dc2e790ff6daa9df31cfa0ed7cd (patch)
treeceeef9c344d5cd45a497fc97e0b9cb1a7a8e2b20 /db
parent96ce018912ceffb7270b883a8982b1e2403cda1c (diff)
Arregladas migraciones de tabla Carts
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20230405013826_create_carts.rb5
-rw-r--r--db/schema.rb7
2 files changed, 8 insertions, 4 deletions
diff --git a/db/migrate/20230405013826_create_carts.rb b/db/migrate/20230405013826_create_carts.rb
index 8975e61..f66e030 100644
--- a/db/migrate/20230405013826_create_carts.rb
+++ b/db/migrate/20230405013826_create_carts.rb
@@ -1,9 +1,10 @@
class CreateCarts < ActiveRecord::Migration[7.0]
def change
create_table :carts do |t|
- t.belongs_to :user_account, null: false, index: { unique: true }, foreign_key: true
-
t.timestamps
end
+
+ add_reference :user_accounts, :cart, foreign_key: true
+ add_reference :carts, :user_account, foreign_key: true
end
end
diff --git a/db/schema.rb b/db/schema.rb
index b974771..4020c8d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -62,10 +62,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_015505) do
end
create_table "carts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
- t.bigint "user_account_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.index ["user_account_id"], name: "index_carts_on_user_account_id", unique: true
+ t.bigint "user_account_id"
+ t.index ["user_account_id"], name: "index_carts_on_user_account_id"
end
create_table "companies", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
@@ -131,6 +131,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_05_015505) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "role"
+ t.bigint "cart_id"
+ t.index ["cart_id"], name: "index_user_accounts_on_cart_id"
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
@@ -140,4 +142,5 @@ 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_accounts", "carts"
end