From cd04bcc4b4e4f5174d2f042bfcf6b840e6e18fee Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 2 May 2021 20:28:53 -0400 Subject: Add Characters --- db/migrate/20210503002720_create_characters.rb | 15 +++++++++++++++ db/schema.rb | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20210503002720_create_characters.rb (limited to 'db') diff --git a/db/migrate/20210503002720_create_characters.rb b/db/migrate/20210503002720_create_characters.rb new file mode 100644 index 0000000..1420a0b --- /dev/null +++ b/db/migrate/20210503002720_create_characters.rb @@ -0,0 +1,15 @@ +class CreateCharacters < ActiveRecord::Migration[6.1] + def change + create_table :characters do |t| + t.string :name + t.references :user, null: false, foreign_key: true + t.references :activity, foreign_key: true + t.timestamp :activity_started_at + t.timestamp :recent_request_at + + t.timestamps + end + + add_reference :users, :active_character, foreign_key: { to_table: :characters } + end +end diff --git a/db/schema.rb b/db/schema.rb index 85aa952..9072ac3 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_001859) do +ActiveRecord::Schema.define(version: 2021_05_03_002720) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -24,6 +24,18 @@ ActiveRecord::Schema.define(version: 2021_05_03_001859) do t.datetime "updated_at", precision: 6, null: false end + create_table "characters", force: :cascade do |t| + t.string "name" + t.bigint "user_id", null: false + t.bigint "activity_id" + t.datetime "activity_started_at" + t.datetime "recent_request_at" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["activity_id"], name: "index_characters_on_activity_id" + t.index ["user_id"], name: "index_characters_on_user_id" + end + create_table "items", force: :cascade do |t| t.string "gid" t.string "name" @@ -63,10 +75,15 @@ ActiveRecord::Schema.define(version: 2021_05_03_001859) do t.datetime "locked_at" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.bigint "active_character_id" + t.index ["active_character_id"], name: "index_users_on_active_character_id" t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true end + add_foreign_key "characters", "activities" + add_foreign_key "characters", "users" + add_foreign_key "users", "characters", column: "active_character_id" end -- cgit v1.2.3