Add foreign keys and an index to StructuredError(Attributes)
These changes will ensure a better data consistency and faster access. We further ensure that records should be deleted properly.
This commit is contained in:
@ -4,7 +4,7 @@ class StructuredError < ApplicationRecord
|
|||||||
belongs_to :error_template
|
belongs_to :error_template
|
||||||
belongs_to :submission
|
belongs_to :submission
|
||||||
|
|
||||||
has_many :structured_error_attributes
|
has_many :structured_error_attributes, dependent: :destroy
|
||||||
|
|
||||||
def self.create_from_template(template, message_buffer, submission)
|
def self.create_from_template(template, message_buffer, submission)
|
||||||
create(
|
create(
|
||||||
|
@ -15,7 +15,7 @@ class Submission < ApplicationRecord
|
|||||||
belongs_to :study_group, optional: true
|
belongs_to :study_group, optional: true
|
||||||
|
|
||||||
has_many :testruns
|
has_many :testruns
|
||||||
has_many :structured_errors
|
has_many :structured_errors, dependent: :destroy
|
||||||
has_many :comments, through: :files
|
has_many :comments, through: :files
|
||||||
|
|
||||||
belongs_to :external_users, lambda {
|
belongs_to :external_users, lambda {
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddForeignKeysToStructuredErrors < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_foreign_key :structured_errors, :submissions
|
||||||
|
add_foreign_key :structured_errors, :error_templates
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddForeignKeysAndIndexToStructuredErrorAttributes < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_foreign_key :structured_error_attributes, :structured_errors
|
||||||
|
add_foreign_key :structured_error_attributes, :error_template_attributes
|
||||||
|
add_index :structured_error_attributes, :structured_error_id
|
||||||
|
end
|
||||||
|
end
|
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.0].define(version: 2023_03_14_084733) do
|
ActiveRecord::Schema[7.0].define(version: 2023_03_20_220012) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pg_trgm"
|
enable_extension "pg_trgm"
|
||||||
enable_extension "pgcrypto"
|
enable_extension "pgcrypto"
|
||||||
@ -420,6 +420,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_14_084733) do
|
|||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.boolean "match"
|
t.boolean "match"
|
||||||
|
t.index ["structured_error_id"], name: "index_structured_error_attributes_on_structured_error_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "structured_errors", id: :serial, force: :cascade do |t|
|
create_table "structured_errors", id: :serial, force: :cascade do |t|
|
||||||
@ -600,6 +601,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_14_084733) do
|
|||||||
add_foreign_key "exercise_tips", "exercises"
|
add_foreign_key "exercise_tips", "exercises"
|
||||||
add_foreign_key "exercise_tips", "tips"
|
add_foreign_key "exercise_tips", "tips"
|
||||||
add_foreign_key "remote_evaluation_mappings", "study_groups"
|
add_foreign_key "remote_evaluation_mappings", "study_groups"
|
||||||
|
add_foreign_key "structured_error_attributes", "error_template_attributes"
|
||||||
|
add_foreign_key "structured_error_attributes", "structured_errors"
|
||||||
|
add_foreign_key "structured_errors", "error_templates"
|
||||||
|
add_foreign_key "structured_errors", "error_templates", name: "structured_errors_error_templates_id_fk"
|
||||||
|
add_foreign_key "structured_errors", "submissions"
|
||||||
add_foreign_key "submissions", "study_groups"
|
add_foreign_key "submissions", "study_groups"
|
||||||
add_foreign_key "subscriptions", "study_groups"
|
add_foreign_key "subscriptions", "study_groups"
|
||||||
add_foreign_key "testrun_execution_environments", "execution_environments"
|
add_foreign_key "testrun_execution_environments", "execution_environments"
|
||||||
|
Reference in New Issue
Block a user