From f296318072fb2b66a86afd15f78ad5de9c9eee9a Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 19 Aug 2019 16:12:30 +0200 Subject: [PATCH] Create GroupeInstructeur --- app/models/groupe_instructeur.rb | 3 +++ app/models/procedure.rb | 1 + .../20190819134252_create_groupe_instructeurs.rb | 12 ++++++++++++ db/schema.rb | 12 +++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/models/groupe_instructeur.rb create mode 100644 db/migrate/20190819134252_create_groupe_instructeurs.rb diff --git a/app/models/groupe_instructeur.rb b/app/models/groupe_instructeur.rb new file mode 100644 index 000000000..6c8453f26 --- /dev/null +++ b/app/models/groupe_instructeur.rb @@ -0,0 +1,3 @@ +class GroupeInstructeur < ApplicationRecord + belongs_to :procedure +end diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 9536829fb..ef26e3153 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -18,6 +18,7 @@ class Procedure < ApplicationRecord has_many :administrateurs_procedures has_many :administrateurs, through: :administrateurs_procedures, after_remove: -> (procedure, _admin) { procedure.validate! } has_many :instructeurs, through: :assign_to + has_many :groupe_instructeurs, dependent: :destroy has_one :initiated_mail, class_name: "Mails::InitiatedMail", dependent: :destroy has_one :received_mail, class_name: "Mails::ReceivedMail", dependent: :destroy diff --git a/db/migrate/20190819134252_create_groupe_instructeurs.rb b/db/migrate/20190819134252_create_groupe_instructeurs.rb new file mode 100644 index 000000000..df90219b3 --- /dev/null +++ b/db/migrate/20190819134252_create_groupe_instructeurs.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index fdbf8f457..a6f024915 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # 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 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" 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| t.string "nom" t.string "prenom" @@ -638,6 +647,7 @@ ActiveRecord::Schema.define(version: 2019_08_09_073736) do add_foreign_key "dossiers", "users" add_foreign_key "feedbacks", "users" add_foreign_key "geo_areas", "champs" + add_foreign_key "groupe_instructeurs", "procedures" add_foreign_key "initiated_mails", "procedures" add_foreign_key "procedure_presentations", "assign_tos" add_foreign_key "procedures", "services"