Create GroupeInstructeur

This commit is contained in:
simon lehericey 2019-08-19 16:12:30 +02:00
parent e47925e18e
commit f296318072
4 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,3 @@
class GroupeInstructeur < ApplicationRecord
belongs_to :procedure
end

View file

@ -18,6 +18,7 @@ class Procedure < ApplicationRecord
has_many :administrateurs_procedures has_many :administrateurs_procedures
has_many :administrateurs, through: :administrateurs_procedures, after_remove: -> (procedure, _admin) { procedure.validate! } has_many :administrateurs, through: :administrateurs_procedures, after_remove: -> (procedure, _admin) { procedure.validate! }
has_many :instructeurs, through: :assign_to has_many :instructeurs, through: :assign_to
has_many :groupe_instructeurs, dependent: :destroy
has_one :initiated_mail, class_name: "Mails::InitiatedMail", dependent: :destroy has_one :initiated_mail, class_name: "Mails::InitiatedMail", dependent: :destroy
has_one :received_mail, class_name: "Mails::ReceivedMail", dependent: :destroy has_one :received_mail, class_name: "Mails::ReceivedMail", dependent: :destroy

View file

@ -0,0 +1,12 @@
class CreateGroupeInstructeurs < ActiveRecord::Migration[5.2]
def change
create_table :groupe_instructeurs do |t|
t.references :procedure, foreign_key: true, null: false
t.text :label, null: false
t.timestamps
end
add_index :groupe_instructeurs, [:procedure_id, :label], unique: true
end
end

View file

@ -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: 2019_08_09_073736) do ActiveRecord::Schema.define(version: 2019_08_19_134252) 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"
@ -391,6 +391,15 @@ ActiveRecord::Schema.define(version: 2019_08_09_073736) do
t.index ["source"], name: "index_geo_areas_on_source" t.index ["source"], name: "index_geo_areas_on_source"
end end
create_table "groupe_instructeurs", force: :cascade do |t|
t.bigint "procedure_id", null: false
t.text "label", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["procedure_id", "label"], name: "index_groupe_instructeurs_on_procedure_id_and_label", unique: true
t.index ["procedure_id"], name: "index_groupe_instructeurs_on_procedure_id"
end
create_table "individuals", id: :serial, force: :cascade do |t| create_table "individuals", id: :serial, force: :cascade do |t|
t.string "nom" t.string "nom"
t.string "prenom" t.string "prenom"
@ -638,6 +647,7 @@ ActiveRecord::Schema.define(version: 2019_08_09_073736) do
add_foreign_key "dossiers", "users" add_foreign_key "dossiers", "users"
add_foreign_key "feedbacks", "users" add_foreign_key "feedbacks", "users"
add_foreign_key "geo_areas", "champs" add_foreign_key "geo_areas", "champs"
add_foreign_key "groupe_instructeurs", "procedures"
add_foreign_key "initiated_mails", "procedures" add_foreign_key "initiated_mails", "procedures"
add_foreign_key "procedure_presentations", "assign_tos" add_foreign_key "procedure_presentations", "assign_tos"
add_foreign_key "procedures", "services" add_foreign_key "procedures", "services"