summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20210529195709_create_conditions.rb12
-rw-r--r--db/migrate/20210529195809_create_states.rb11
-rw-r--r--db/schema.rb23
-rw-r--r--db/seeds.rb5
4 files changed, 50 insertions, 1 deletions
diff --git a/db/migrate/20210529195709_create_conditions.rb b/db/migrate/20210529195709_create_conditions.rb
new file mode 100644
index 0000000..8330fcb
--- /dev/null
+++ b/db/migrate/20210529195709_create_conditions.rb
@@ -0,0 +1,12 @@
+class CreateConditions < ActiveRecord::Migration[6.1]
+ def change
+ create_table :conditions do |t|
+ t.string :gid
+ t.string :name
+ t.text :description
+ t.jsonb :whatnot
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20210529195809_create_states.rb b/db/migrate/20210529195809_create_states.rb
new file mode 100644
index 0000000..6922e0a
--- /dev/null
+++ b/db/migrate/20210529195809_create_states.rb
@@ -0,0 +1,11 @@
+class CreateStates < ActiveRecord::Migration[6.1]
+ def change
+ create_table :states do |t|
+ t.references :character, null: false, foreign_key: true
+ t.references :condition, null: false, foreign_key: true
+ t.timestamp :expires_at
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index eae72c9..5d9fffe 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_27_002712) do
+ActiveRecord::Schema.define(version: 2021_05_29_195809) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -109,6 +109,15 @@ ActiveRecord::Schema.define(version: 2021_05_27_002712) do
t.datetime "updated_at", precision: 6, null: false
end
+ create_table "conditions", force: :cascade do |t|
+ t.string "gid"
+ t.string "name"
+ t.text "description"
+ t.jsonb "whatnot"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ end
+
create_table "equipment", force: :cascade do |t|
t.bigint "character_id", null: false
t.bigint "item_id", null: false
@@ -183,6 +192,16 @@ ActiveRecord::Schema.define(version: 2021_05_27_002712) do
t.index ["gid"], name: "index_skills_on_gid"
end
+ create_table "states", force: :cascade do |t|
+ t.bigint "character_id", null: false
+ t.bigint "condition_id", null: false
+ t.datetime "expires_at"
+ t.datetime "created_at", precision: 6, null: false
+ t.datetime "updated_at", precision: 6, null: false
+ t.index ["character_id"], name: "index_states_on_character_id"
+ t.index ["condition_id"], name: "index_states_on_condition_id"
+ end
+
create_table "title_awards", force: :cascade do |t|
t.bigint "title_id", null: false
t.bigint "character_id", null: false
@@ -247,6 +266,8 @@ ActiveRecord::Schema.define(version: 2021_05_27_002712) do
add_foreign_key "hearths", "characters"
add_foreign_key "learned_activities", "activities"
add_foreign_key "learned_activities", "characters"
+ add_foreign_key "states", "characters"
+ add_foreign_key "states", "conditions"
add_foreign_key "title_awards", "characters"
add_foreign_key "title_awards", "titles"
add_foreign_key "users", "characters", column: "active_character_id"
diff --git a/db/seeds.rb b/db/seeds.rb
index a1459cc..1e2888a 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -51,3 +51,8 @@ load_data_file("data/monsters.yml").map do |gid, hash|
monster = Monster.find_or_create_by(gid: gid)
monster.update(hash)
end
+
+load_data_file("data/conditions.yml").map do |gid, hash|
+ condition = Condition.find_or_create_by(gid: gid)
+ condition.update(hash)
+end