Verified Commit 51eeffa2 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

add relation between semester_process and hours

parent 438fe100
...@@ -12,6 +12,8 @@ class Hour < ApplicationRecord ...@@ -12,6 +12,8 @@ class Hour < ApplicationRecord
belongs_to :billing_expense, -> { with_deleted }, optional: true, inverse_of: 'hours' belongs_to :billing_expense, -> { with_deleted }, optional: true, inverse_of: 'hours'
belongs_to :certificate, optional: true belongs_to :certificate, optional: true
belongs_to :semester_process_volunteer, optional: true
validates :hours, presence: true, numericality: { greater_than: 0 } validates :hours, presence: true, numericality: { greater_than: 0 }
validates :meeting_date, presence: true validates :meeting_date, presence: true
validates :hourable, presence: true validates :hourable, presence: true
......
...@@ -9,4 +9,5 @@ class SemesterProcessVolunteer < ApplicationRecord ...@@ -9,4 +9,5 @@ class SemesterProcessVolunteer < ApplicationRecord
inverse_of: 'semester_processes', optional: true inverse_of: 'semester_processes', optional: true
has_many :semester_feedbacks, dependent: :destroy has_many :semester_feedbacks, dependent: :destroy
has_many :hours, dependent: :nullify
end end
class AddRelationBetweenSemesterProcessAndHour < ActiveRecord::Migration[5.1]
def change
change_table :hours do |t|
t.references :semester_process_volunteer, foreign_key: true
end
end
end
...@@ -10,7 +10,7 @@ ...@@ -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.define(version: 20181004144449) do ActiveRecord::Schema.define(version: 20181004163636) 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 "plpgsql" enable_extension "plpgsql"
...@@ -489,6 +489,7 @@ ActiveRecord::Schema.define(version: 20181004144449) do ...@@ -489,6 +489,7 @@ ActiveRecord::Schema.define(version: 20181004144449) do
t.string "hourable_type" t.string "hourable_type"
t.bigint "hourable_id" t.bigint "hourable_id"
t.bigint "reviewer_id" t.bigint "reviewer_id"
t.bigint "semester_process_volunteer_id"
t.index ["billing_expense_id"], name: "index_hours_on_billing_expense_id" t.index ["billing_expense_id"], name: "index_hours_on_billing_expense_id"
t.index ["deleted_at"], name: "index_hours_on_deleted_at" t.index ["deleted_at"], name: "index_hours_on_deleted_at"
t.index ["hourable_type", "hourable_id"], name: "index_hours_on_hourable_type_and_hourable_id" t.index ["hourable_type", "hourable_id"], name: "index_hours_on_hourable_type_and_hourable_id"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment