diff options
author | David Gay <eapoems@riseup.net> | 2023-10-30 01:06:05 -0400 |
---|---|---|
committer | David Gay <eapoems@riseup.net> | 2023-10-30 01:06:05 -0400 |
commit | 5e7909e61695d002d45ce58fa010502c5eb8da51 (patch) | |
tree | 4196596af1edc31a6ba073a09e53a0ac32d02807 /db | |
parent | f47ca741d81a8de56fdd1cee1114b9c676d8b245 (diff) |
Game, Run, Checkpoint models
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20231030045243_create_games.rb | 9 | ||||
-rw-r--r-- | db/migrate/20231030045347_create_runs.rb | 12 | ||||
-rw-r--r-- | db/migrate/20231030045720_create_checkpoints.rb | 12 | ||||
-rw-r--r-- | db/schema.rb | 34 |
4 files changed, 66 insertions, 1 deletions
diff --git a/db/migrate/20231030045243_create_games.rb b/db/migrate/20231030045243_create_games.rb new file mode 100644 index 0000000..a46c0cc --- /dev/null +++ b/db/migrate/20231030045243_create_games.rb @@ -0,0 +1,9 @@ +class CreateGames < ActiveRecord::Migration[7.1] + def change + create_table :games do |t| + t.string :title, null: false + + t.timestamps + end + end +end diff --git a/db/migrate/20231030045347_create_runs.rb b/db/migrate/20231030045347_create_runs.rb new file mode 100644 index 0000000..a0aaba1 --- /dev/null +++ b/db/migrate/20231030045347_create_runs.rb @@ -0,0 +1,12 @@ +class CreateRuns < ActiveRecord::Migration[7.1] + def change + create_table :runs do |t| + t.string :title, null: false + t.text :description + t.references :game, null: false, foreign_key: true + t.references :user, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20231030045720_create_checkpoints.rb b/db/migrate/20231030045720_create_checkpoints.rb new file mode 100644 index 0000000..21ec35c --- /dev/null +++ b/db/migrate/20231030045720_create_checkpoints.rb @@ -0,0 +1,12 @@ +class CreateCheckpoints < ActiveRecord::Migration[7.1] + def change + create_table :checkpoints do |t| + t.string :title + t.text :description + t.references :run, null: false, foreign_key: true + t.references :user, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5f2f919..af7e6a0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,38 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_10_30_040016) do +ActiveRecord::Schema[7.1].define(version: 2023_10_30_045720) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "checkpoints", force: :cascade do |t| + t.string "title" + t.text "description" + t.bigint "run_id", null: false + t.bigint "user_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["run_id"], name: "index_checkpoints_on_run_id" + t.index ["user_id"], name: "index_checkpoints_on_user_id" + end + + create_table "games", force: :cascade do |t| + t.string "title", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "runs", force: :cascade do |t| + t.string "title", null: false + t.text "description" + t.bigint "game_id", null: false + t.bigint "user_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["game_id"], name: "index_runs_on_game_id" + t.index ["user_id"], name: "index_runs_on_user_id" + end + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -23,4 +51,8 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_30_040016) do t.index ["email"], name: "index_users_on_email", unique: true end + add_foreign_key "checkpoints", "runs" + add_foreign_key "checkpoints", "users" + add_foreign_key "runs", "games" + add_foreign_key "runs", "users" end |