add expert to avis table
This commit is contained in:
parent
efbff0f2e0
commit
b683c2023b
4 changed files with 25 additions and 13 deletions
|
@ -12,6 +12,7 @@
|
|||
# updated_at :datetime not null
|
||||
# claimant_id :integer not null
|
||||
# dossier_id :integer
|
||||
# experts_procedure_id :bigint
|
||||
# instructeur_id :integer
|
||||
#
|
||||
class Avis < ApplicationRecord
|
||||
|
@ -19,10 +20,12 @@ class Avis < ApplicationRecord
|
|||
|
||||
belongs_to :dossier, inverse_of: :avis, touch: true, optional: false
|
||||
belongs_to :instructeur, optional: true
|
||||
belongs_to :experts_procedure, optional: true
|
||||
belongs_to :claimant, class_name: 'Instructeur', optional: false
|
||||
|
||||
has_one_attached :piece_justificative_file
|
||||
has_one_attached :introduction_file
|
||||
has_one :expert, through: :experts_procedure
|
||||
|
||||
validates :piece_justificative_file,
|
||||
content_type: AUTHORIZED_CONTENT_TYPES,
|
||||
|
|
|
@ -12,5 +12,6 @@
|
|||
class ExpertsProcedure < ApplicationRecord
|
||||
belongs_to :expert
|
||||
belongs_to :procedure
|
||||
validates :expert, uniqueness: { scope: :procedure }
|
||||
|
||||
has_many :avis, dependent: :destroy
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddExpertsProcedureToAvis < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_reference :avis, :experts_procedure, foreign_key: true
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_01_13_150013) do
|
||||
ActiveRecord::Schema.define(version: 2021_01_13_084256) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -121,8 +121,10 @@ ActiveRecord::Schema.define(version: 2021_01_13_150013) do
|
|||
t.integer "claimant_id", null: false
|
||||
t.boolean "confidentiel", default: false, null: false
|
||||
t.datetime "revoked_at"
|
||||
t.bigint "experts_procedure_id"
|
||||
t.index ["claimant_id"], name: "index_avis_on_claimant_id"
|
||||
t.index ["dossier_id"], name: "index_avis_on_dossier_id"
|
||||
t.index ["experts_procedure_id"], name: "index_avis_on_experts_procedure_id"
|
||||
t.index ["instructeur_id"], name: "index_avis_on_instructeur_id"
|
||||
end
|
||||
|
||||
|
@ -723,6 +725,7 @@ ActiveRecord::Schema.define(version: 2021_01_13_150013) do
|
|||
add_foreign_key "assign_tos", "groupe_instructeurs"
|
||||
add_foreign_key "attestation_templates", "procedures"
|
||||
add_foreign_key "attestations", "dossiers"
|
||||
add_foreign_key "avis", "experts_procedures"
|
||||
add_foreign_key "avis", "instructeurs", column: "claimant_id"
|
||||
add_foreign_key "champs", "champs", column: "parent_id"
|
||||
add_foreign_key "closed_mails", "procedures"
|
||||
|
|
Loading…
Reference in a new issue