From 1b2de86007508ba86c6c9cb99fbdcac178045131 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 2 May 2021 22:38:32 -0400 Subject: Character items and inventory, with ability to add and remove items --- db/migrate/20210503005919_create_character_items.rb | 11 +++++++++++ db/schema.rb | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210503005919_create_character_items.rb (limited to 'db') diff --git a/db/migrate/20210503005919_create_character_items.rb b/db/migrate/20210503005919_create_character_items.rb new file mode 100644 index 0000000..50e926a --- /dev/null +++ b/db/migrate/20210503005919_create_character_items.rb @@ -0,0 +1,11 @@ +class CreateCharacterItems < ActiveRecord::Migration[6.1] + def change + create_table :character_items do |t| + t.references :character, null: false, foreign_key: true + t.references :item, null: false, foreign_key: true + t.integer :quantity + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9072ac3..a86c111 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: 2021_05_03_002720) do +ActiveRecord::Schema.define(version: 2021_05_03_005919) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -24,6 +24,16 @@ ActiveRecord::Schema.define(version: 2021_05_03_002720) do t.datetime "updated_at", precision: 6, null: false end + create_table "character_items", force: :cascade do |t| + t.bigint "character_id", null: false + t.bigint "item_id", null: false + t.integer "quantity" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["character_id"], name: "index_character_items_on_character_id" + t.index ["item_id"], name: "index_character_items_on_item_id" + end + create_table "characters", force: :cascade do |t| t.string "name" t.bigint "user_id", null: false @@ -83,6 +93,8 @@ ActiveRecord::Schema.define(version: 2021_05_03_002720) do t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true end + add_foreign_key "character_items", "characters" + add_foreign_key "character_items", "items" add_foreign_key "characters", "activities" add_foreign_key "characters", "users" add_foreign_key "users", "characters", column: "active_character_id" -- cgit v1.2.3