Skip to content

Commit

Permalink
Allow null for saved annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Jun 26, 2024
1 parent d76103a commit 31334ce
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/models/activity_read_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# user_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# series_id :integer
#
class ActivityReadState < ApplicationRecord
belongs_to :activity
Expand Down
8 changes: 4 additions & 4 deletions app/models/saved_annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# title :string(255) not null
# annotation_text :text(16777215)
# user_id :integer not null
# exercise_id :integer not null
# course_id :integer not null
# exercise_id :integer
# course_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# annotations_count :integer default(0)
Expand All @@ -17,8 +17,8 @@ class SavedAnnotation < ApplicationRecord
validates :annotation_text, presence: true

belongs_to :user
belongs_to :exercise
belongs_to :course
belongs_to :exercise, optional: true
belongs_to :course, optional: true

has_many :annotations, dependent: :nullify
has_many :submissions, through: :annotations
Expand Down
1 change: 1 addition & 0 deletions app/models/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# fs_key :string(24)
# number :integer
# annotated :boolean default(FALSE), not null
# series_id :integer
#

class Submission < ApplicationRecord
Expand Down
8 changes: 5 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_03_07_124219) do
ActiveRecord::Schema[7.1].define(version: 2024_06_26_093130) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
Expand Down Expand Up @@ -82,6 +82,7 @@
t.integer "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "series_id"
t.index ["activity_id", "course_id", "user_id"], name: "activity_read_states_unique", unique: true
t.index ["course_id"], name: "fk_rails_f674cacc14"
t.index ["user_id"], name: "fk_rails_96d00253e9"
Expand Down Expand Up @@ -420,8 +421,8 @@
t.string "title", null: false
t.text "annotation_text", size: :medium
t.integer "user_id", null: false
t.integer "exercise_id", null: false
t.integer "course_id", null: false
t.integer "exercise_id"
t.integer "course_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "annotations_count", default: 0
Expand Down Expand Up @@ -499,6 +500,7 @@
t.string "fs_key", limit: 24
t.integer "number"
t.boolean "annotated", default: false, null: false
t.integer "series_id"
t.index ["accepted"], name: "index_submissions_on_accepted"
t.index ["course_id"], name: "index_submissions_on_course_id"
t.index ["exercise_id", "status", "course_id"], name: "ex_st_co_idx"
Expand Down
4 changes: 2 additions & 2 deletions test/factories/saved_annotations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# title :string(255) not null
# annotation_text :text(16777215)
# user_id :integer not null
# exercise_id :integer not null
# course_id :integer not null
# exercise_id :integer
# course_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# annotations_count :integer default(0)
Expand Down
1 change: 1 addition & 0 deletions test/factories/submissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# fs_key :string(24)
# number :integer
# annotated :boolean default(FALSE), not null
# series_id :integer
#

FactoryBot.define do
Expand Down
1 change: 1 addition & 0 deletions test/models/activity_read_state_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# user_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# series_id :integer
#

require 'test_helper'
Expand Down
4 changes: 2 additions & 2 deletions test/models/saved_annotation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# title :string(255) not null
# annotation_text :text(16777215)
# user_id :integer not null
# exercise_id :integer not null
# course_id :integer not null
# exercise_id :integer
# course_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# annotations_count :integer default(0)
Expand Down
1 change: 1 addition & 0 deletions test/models/submission_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# fs_key :string(24)
# number :integer
# annotated :boolean default(FALSE), not null
# series_id :integer
#

require 'test_helper'
Expand Down

0 comments on commit 31334ce

Please sign in to comment.