diff --git a/app/models/work_item.rb b/app/models/work_item.rb new file mode 100644 index 0000000..4a444ea --- /dev/null +++ b/app/models/work_item.rb @@ -0,0 +1,3 @@ +class WorkItem < ApplicationRecord + belongs_to :course +end diff --git a/db/migrate/20231007144031_create_work_items.rb b/db/migrate/20231007144031_create_work_items.rb new file mode 100644 index 0000000..c610ce9 --- /dev/null +++ b/db/migrate/20231007144031_create_work_items.rb @@ -0,0 +1,11 @@ +class CreateWorkItems < ActiveRecord::Migration[7.1] + def change + create_table :work_items do |t| + t.string :title, null: false + t.references :course, null: false, foreign_key: true + t.datetime :due_date, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1fe7db4..17846e7 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[7.1].define(version: 2023_10_06_210710) do +ActiveRecord::Schema[7.1].define(version: 2023_10_07_144031) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -60,6 +60,16 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_06_210710) do t.index ["lecture_id"], name: "index_tracked_time_entries_on_lecture_id" end + create_table "work_items", force: :cascade do |t| + t.string "title", null: false + t.bigint "course_id", null: false + t.datetime "due_date", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["course_id"], name: "index_work_items_on_course_id" + end + add_foreign_key "recordings", "courses" add_foreign_key "tracked_time_entries", "lectures" + add_foreign_key "work_items", "courses" end diff --git a/test/fixtures/work_items.yml b/test/fixtures/work_items.yml new file mode 100644 index 0000000..0e15f85 --- /dev/null +++ b/test/fixtures/work_items.yml @@ -0,0 +1,11 @@ +# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + course: one + due_date07/10/2023: MyString + +two: + title: MyString + course: two + due_date07/10/2023: MyString diff --git a/test/models/work_item_test.rb b/test/models/work_item_test.rb new file mode 100644 index 0000000..5975589 --- /dev/null +++ b/test/models/work_item_test.rb @@ -0,0 +1,7 @@ +require "test_helper" + +class WorkItemTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end