Add completions
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run

This commit is contained in:
sto
2025-03-20 11:12:55 +01:00
parent 44507bb85c
commit a03907f756
20 changed files with 213 additions and 14 deletions

View File

@@ -0,0 +1,11 @@
class CreateCompletions < ActiveRecord::Migration[8.0]
def change
create_table :completions do |t|
t.integer :time_seconds
t.belongs_to :contestant, null: false, foreign_key: true
t.belongs_to :puzzle, null: false, foreign_key: true
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddContestRefToCompletion < ActiveRecord::Migration[8.0]
def change
add_reference :completions, :contest, null: false, foreign_key: true
end
end

17
db/schema.rb generated
View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2025_03_20_080142) do
ActiveRecord::Schema[8.0].define(version: 2025_03_20_093759) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -39,6 +39,18 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_20_080142) do
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
create_table "completions", force: :cascade do |t|
t.integer "time_seconds"
t.integer "contestant_id", null: false
t.integer "puzzle_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "contest_id", null: false
t.index ["contest_id"], name: "index_completions_on_contest_id"
t.index ["contestant_id"], name: "index_completions_on_contestant_id"
t.index ["puzzle_id"], name: "index_completions_on_puzzle_id"
end
create_table "contestants", force: :cascade do |t|
t.string "name"
t.string "email"
@@ -87,6 +99,9 @@ ActiveRecord::Schema[8.0].define(version: 2025_03_20_080142) do
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "completions", "contestants"
add_foreign_key "completions", "contests"
add_foreign_key "completions", "puzzles"
add_foreign_key "contestants", "contests"
add_foreign_key "contests", "users"
add_foreign_key "puzzles", "contests"