Update schema to reflect re-usable error_template_attributes, descriptions, hints, and sorting

This commit is contained in:
Maximilian Grundke
2017-07-11 19:22:12 +02:00
parent d2a089d057
commit 872611bff6
6 changed files with 30 additions and 5 deletions

View File

@ -1,3 +1,4 @@
class ErrorTemplate < ActiveRecord::Base
belongs_to :execution_environment
has_and_belongs_to_many :error_template_attributes
end

View File

@ -1,3 +1,3 @@
class ErrorTemplateAttribute < ActiveRecord::Base
belongs_to :error_template
has_and_belongs_to_many :error_template
end

View File

@ -11,6 +11,7 @@ class ExecutionEnvironment < ActiveRecord::Base
has_many :exercises
belongs_to :file_type
has_many :hints
has_many :error_templates
scope :with_exercises, -> { where('id IN (SELECT execution_environment_id FROM exercises)') }

View File

@ -0,0 +1,9 @@
class AddDescriptionAndHintToErrorTemplate < ActiveRecord::Migration
def change
add_column :error_templates, :description, :text
add_column :error_templates, :hint, :text
add_column :error_template_attributes, :description, :text
add_column :error_template_attributes, :important, :boolean
end
end

View File

@ -0,0 +1,6 @@
class ChangeErrorTemplateAttributeRelationshipToNToM < ActiveRecord::Migration
def change
remove_belongs_to :error_template_attributes, :error_template
create_join_table :error_templates, :error_template_attributes
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170703080355) do
ActiveRecord::Schema.define(version: 20170711170928) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -48,11 +48,17 @@ ActiveRecord::Schema.define(version: 20170703080355) do
end
create_table "error_template_attributes", force: :cascade do |t|
t.integer "error_template_id"
t.string "key"
t.string "regex"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "description"
t.boolean "important"
end
create_table "error_template_attributes_templates", id: false, force: :cascade do |t|
t.integer "error_template_id", null: false
t.integer "error_template_attribute_id", null: false
end
create_table "error_templates", force: :cascade do |t|
@ -61,6 +67,8 @@ ActiveRecord::Schema.define(version: 20170703080355) do
t.string "signature"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "description"
t.text "hint"
end
create_table "errors", force: :cascade do |t|