nouveau model InstructeursProcedure avec position

This commit is contained in:
benoitqueyron 2024-11-19 16:11:32 +01:00
parent 5a2ab37049
commit 64f39e2c78
No known key found for this signature in database
GPG key ID: AD3C38C9ACA84135
5 changed files with 37 additions and 1 deletions

View file

@ -27,6 +27,8 @@ class Instructeur < ApplicationRecord
has_many :exports, as: :user_profile has_many :exports, as: :user_profile
has_many :archives, as: :user_profile has_many :archives, as: :user_profile
has_many :instructeurs_procedures, dependent: :destroy
belongs_to :user belongs_to :user
scope :with_instant_email_message_notifications, -> { scope :with_instant_email_message_notifications, -> {

View file

@ -0,0 +1,4 @@
class InstructeursProcedure < ApplicationRecord
belongs_to :instructeur
belongs_to :procedure
end

View file

@ -63,6 +63,8 @@ class Procedure < ApplicationRecord
has_many :bulk_messages, dependent: :destroy has_many :bulk_messages, dependent: :destroy
has_many :labels, dependent: :destroy has_many :labels, dependent: :destroy
has_many :instructeurs_procedures, dependent: :destroy
def active_dossier_submitted_message def active_dossier_submitted_message
published_dossier_submitted_message || draft_dossier_submitted_message published_dossier_submitted_message || draft_dossier_submitted_message
end end

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
class CreateInstructeursProcedures < ActiveRecord::Migration[7.0]
def change
create_table :instructeurs_procedures do |t|
t.references :instructeur, null: false, foreign_key: true
t.references :procedure, null: false, foreign_key: true
t.integer :position
t.timestamps
end
add_index :instructeurs_procedures, [:instructeur_id, :procedure_id], unique: true, name: 'index_instructeurs_procedures_on_instructeur_and_procedure'
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[7.0].define(version: 2024_11_12_090128) do ActiveRecord::Schema[7.0].define(version: 2024_11_19_142129) 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 "pg_buffercache" enable_extension "pg_buffercache"
enable_extension "pg_stat_statements" enable_extension "pg_stat_statements"
@ -819,6 +819,17 @@ ActiveRecord::Schema[7.0].define(version: 2024_11_12_090128) do
t.index ["user_id"], name: "index_instructeurs_on_user_id" t.index ["user_id"], name: "index_instructeurs_on_user_id"
end end
create_table "instructeurs_procedures", force: :cascade do |t|
t.datetime "created_at", null: false
t.bigint "instructeur_id", null: false
t.integer "position"
t.bigint "procedure_id", null: false
t.datetime "updated_at", null: false
t.index ["instructeur_id", "procedure_id"], name: "index_instructeurs_procedures_on_instructeur_and_procedure", unique: true
t.index ["instructeur_id"], name: "index_instructeurs_procedures_on_instructeur_id"
t.index ["procedure_id"], name: "index_instructeurs_procedures_on_procedure_id"
end
create_table "invites", id: :serial, force: :cascade do |t| create_table "invites", id: :serial, force: :cascade do |t|
t.datetime "created_at", precision: nil t.datetime "created_at", precision: nil
t.integer "dossier_id" t.integer "dossier_id"
@ -1323,6 +1334,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_11_12_090128) do
add_foreign_key "groupe_instructeurs", "procedures" add_foreign_key "groupe_instructeurs", "procedures"
add_foreign_key "initiated_mails", "procedures" add_foreign_key "initiated_mails", "procedures"
add_foreign_key "instructeurs", "users" add_foreign_key "instructeurs", "users"
add_foreign_key "instructeurs_procedures", "instructeurs"
add_foreign_key "instructeurs_procedures", "procedures"
add_foreign_key "labels", "procedures" add_foreign_key "labels", "procedures"
add_foreign_key "merge_logs", "users" add_foreign_key "merge_logs", "users"
add_foreign_key "procedure_presentations", "assign_tos" add_foreign_key "procedure_presentations", "assign_tos"