From 376e80e385707ab01019f3c7f12438f2f1417c02 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Fri, 29 Sep 2023 18:20:43 +0100 Subject: [PATCH] Make lectures belong to courses --- app/models/lecture.rb | 2 ++ db/migrate/20230929171856_add_course_id_to_lectures.rb | 5 +++++ db/schema.rb | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230929171856_add_course_id_to_lectures.rb diff --git a/app/models/lecture.rb b/app/models/lecture.rb index 451c38b..89d9b3f 100644 --- a/app/models/lecture.rb +++ b/app/models/lecture.rb @@ -1,4 +1,6 @@ class Lecture < ApplicationRecord + belongs_to :course + enum :status, [ :future, :live, diff --git a/db/migrate/20230929171856_add_course_id_to_lectures.rb b/db/migrate/20230929171856_add_course_id_to_lectures.rb new file mode 100644 index 0000000..24bc05e --- /dev/null +++ b/db/migrate/20230929171856_add_course_id_to_lectures.rb @@ -0,0 +1,5 @@ +class AddCourseIdToLectures < ActiveRecord::Migration[7.0] + def change + add_belongs_to(:lectures, :course) + end +end diff --git a/db/schema.rb b/db/schema.rb index c204c51..2ef1f50 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.0].define(version: 2023_09_29_171730) do +ActiveRecord::Schema[7.0].define(version: 2023_09_29_171856) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -30,6 +30,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_09_29_171730) do t.string "recording_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.bigint "course_id" + t.index ["course_id"], name: "index_lectures_on_course_id" end end