summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-07-11 15:55:19 -0400
committerDavid Gay <david@davidgay.org>2021-07-11 15:55:19 -0400
commit362b92dbebf1ccc529794890153f8c1bfc43637d (patch)
tree532f6901b2e8dfd335262d2ae81ca248af402539 /db
parent1d0f65a3c143c729aea0a22fe4666a8a0cff23c9 (diff)
Give hearths a location
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20210711195205_add_location_to_hearth.rb9
-rw-r--r--db/schema.rb5
2 files changed, 13 insertions, 1 deletions
diff --git a/db/migrate/20210711195205_add_location_to_hearth.rb b/db/migrate/20210711195205_add_location_to_hearth.rb
new file mode 100644
index 0000000..c8031d6
--- /dev/null
+++ b/db/migrate/20210711195205_add_location_to_hearth.rb
@@ -0,0 +1,9 @@
+class AddLocationToHearth < ActiveRecord::Migration[6.1]
+ def change
+ add_reference :hearths, :location, foreign_key: true
+ Hearth.all.each do |hearth|
+ hearth.update(location: Location.find_by_gid("floret"))
+ end
+ change_column :hearths, :location_id, :bigint, null: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3c6cc28..2263181 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_07_06_000053) do
+ActiveRecord::Schema.define(version: 2021_07_11_195205) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -155,7 +155,9 @@ ActiveRecord::Schema.define(version: 2021_07_06_000053) do
t.bigint "character_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
+ t.bigint "location_id", null: false
t.index ["character_id"], name: "index_hearths_on_character_id"
+ t.index ["location_id"], name: "index_hearths_on_location_id"
end
create_table "item_infixes", force: :cascade do |t|
@@ -332,6 +334,7 @@ ActiveRecord::Schema.define(version: 2021_07_06_000053) do
add_foreign_key "hearth_plantings", "hearths"
add_foreign_key "hearth_plantings", "items"
add_foreign_key "hearths", "characters"
+ add_foreign_key "hearths", "locations"
add_foreign_key "item_infixes", "characters"
add_foreign_key "item_infixes", "items"
add_foreign_key "item_infixes", "skills"