From d717f7db2279a35b1259030b9b31e966a341fe99 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 2 May 2021 17:42:23 -0400 Subject: Add items --- db/migrate/20210502212517_create_items.rb | 14 ++++++++++++++ db/schema.rb | 13 ++++++++++++- db/seeds.rb | 10 ++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210502212517_create_items.rb (limited to 'db') diff --git a/db/migrate/20210502212517_create_items.rb b/db/migrate/20210502212517_create_items.rb new file mode 100644 index 0000000..1bb17ce --- /dev/null +++ b/db/migrate/20210502212517_create_items.rb @@ -0,0 +1,14 @@ +class CreateItems < ActiveRecord::Migration[6.1] + def change + create_table :items do |t| + t.string :gid + t.string :name + t.text :description + t.integer :equip_slot + t.boolean :usable + t.jsonb :whatnot + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5fc0f94..67fd0f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,22 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_05_02_200959) do +ActiveRecord::Schema.define(version: 2021_05_02_212517) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "items", force: :cascade do |t| + t.string "gid" + t.string "name" + t.text "description" + t.integer "equip_slot" + t.boolean "usable" + t.jsonb "whatnot" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "skills", force: :cascade do |t| t.string "gid" t.string "name" diff --git a/db/seeds.rb b/db/seeds.rb index 637a355..2008d89 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -14,3 +14,13 @@ load_data_file("data/skills.yml").map do |gid, hash| skill = Skill.find_or_create_by(gid: gid) skill.update(hash) end + +load_data_file("data/items.yml").map do |gid, hash| + item = Item.find_or_create_by(gid: gid) + item.name = hash[:name] + item.description = hash[:description] + item.equip_slot = hash[:equip_slot]&.to_sym + item.usable = hash[:usable] || false + item.whatnot = hash[:whatnot] + item.save +end -- cgit v1.2.3