summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-18 18:16:04 -0400
committerDavid Gay <david@davidgay.org>2021-05-18 18:16:04 -0400
commit4a6c06eb681575dbf1ee58d3b1f667e79051b1e2 (patch)
tree194a555305ec8c12271160a2c7ccf3087f16cd41 /db
parent25c499ae942086b460b886e3d79dc5a55e5f1214 (diff)
Hearths, HearthAmenities, and BuiltHearthAmenities
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20210518002820_create_hearths.rb9
-rw-r--r--db/migrate/20210518214713_create_hearth_amenities.rb13
-rw-r--r--db/migrate/20210518214817_create_built_hearth_amenities.rb11
-rw-r--r--db/schema.rb32
-rw-r--r--db/seeds.rb5
5 files changed, 69 insertions, 1 deletions
diff --git a/db/migrate/20210518002820_create_hearths.rb b/db/migrate/20210518002820_create_hearths.rb
new file mode 100644
index 0000000..051a2e7
--- /dev/null
+++ b/db/migrate/20210518002820_create_hearths.rb
@@ -0,0 +1,9 @@
+class CreateHearths < ActiveRecord::Migration[6.1]
+ def change
+ create_table :hearths do |t|
+ t.references :character, null: false, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210518214713_create_hearth_amenities.rb b/db/migrate/20210518214713_create_hearth_amenities.rb
new file mode 100644
index 0000000..dbbea6d
--- /dev/null
+++ b/db/migrate/20210518214713_create_hearth_amenities.rb
@@ -0,0 +1,13 @@
+class CreateHearthAmenities < ActiveRecord::Migration[6.1]
+ def change
+ create_table :hearth_amenities do |t|
+ t.string :gid
+ t.string :name
+ t.text :description
+ t.jsonb :build_data
+
+ t.timestamps
+ end
+ add_index :hearth_amenities, :gid
+ end
+end
diff --git a/db/migrate/20210518214817_create_built_hearth_amenities.rb b/db/migrate/20210518214817_create_built_hearth_amenities.rb
new file mode 100644
index 0000000..d9c1c5d
--- /dev/null
+++ b/db/migrate/20210518214817_create_built_hearth_amenities.rb
@@ -0,0 +1,11 @@
+class CreateBuiltHearthAmenities < ActiveRecord::Migration[6.1]
+ def change
+ create_table :built_hearth_amenities do |t|
+ t.references :hearth, null: false, foreign_key: true
+ t.references :hearth_amenity, null: false, foreign_key: true
+ t.integer :level
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 626ec36..7cae7d0 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_235646) do
+ActiveRecord::Schema.define(version: 2021_05_18_214817) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -27,6 +27,16 @@ ActiveRecord::Schema.define(version: 2021_05_03_235646) do
t.index ["location_id"], name: "index_activities_on_location_id"
end
+ create_table "built_hearth_amenities", force: :cascade do |t|
+ t.bigint "hearth_id", null: false
+ t.bigint "hearth_amenity_id", null: false
+ t.integer "level"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["hearth_amenity_id"], name: "index_built_hearth_amenities_on_hearth_amenity_id"
+ t.index ["hearth_id"], name: "index_built_hearth_amenities_on_hearth_id"
+ end
+
create_table "character_items", force: :cascade do |t|
t.bigint "character_id", null: false
t.bigint "item_id", null: false
@@ -59,6 +69,23 @@ ActiveRecord::Schema.define(version: 2021_05_03_235646) do
t.index ["user_id"], name: "index_characters_on_user_id"
end
+ create_table "hearth_amenities", force: :cascade do |t|
+ t.string "gid"
+ t.string "name"
+ t.text "description"
+ t.jsonb "build_data"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["gid"], name: "index_hearth_amenities_on_gid"
+ end
+
+ create_table "hearths", force: :cascade do |t|
+ t.bigint "character_id", null: false
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["character_id"], name: "index_hearths_on_character_id"
+ end
+
create_table "items", force: :cascade do |t|
t.string "gid"
t.string "name"
@@ -118,11 +145,14 @@ ActiveRecord::Schema.define(version: 2021_05_03_235646) do
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
end
+ add_foreign_key "built_hearth_amenities", "hearth_amenities"
+ add_foreign_key "built_hearth_amenities", "hearths"
add_foreign_key "character_items", "characters"
add_foreign_key "character_items", "items"
add_foreign_key "character_skills", "characters"
add_foreign_key "character_skills", "skills"
add_foreign_key "characters", "activities"
add_foreign_key "characters", "users"
+ add_foreign_key "hearths", "characters"
add_foreign_key "users", "characters", column: "active_character_id"
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 7fcd125..cf4caa6 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -34,3 +34,8 @@ load_data_file("data/activities.yml").map do |gid, hash|
activity.location = Location.find_by_gid(hash[:location])
activity.save
end
+
+load_data_file("data/hearth_amenities.yml").map do |gid, hash|
+ hearth_amenity = HearthAmenity.find_or_create_by(gid: gid)
+ hearth_amenity.update(hash)
+end