create dossier_labels

This commit is contained in:
Lisa Durand 2024-09-25 16:03:58 +02:00
parent 96cfb6cc43
commit 2006dd283f
No known key found for this signature in database
GPG key ID: 0DF91F2CA1E8B816
5 changed files with 32 additions and 0 deletions

View file

@ -132,6 +132,8 @@ class Dossier < ApplicationRecord
belongs_to :transfer, class_name: 'DossierTransfer', foreign_key: 'dossier_transfer_id', optional: true, inverse_of: :dossiers
has_many :transfer_logs, class_name: 'DossierTransferLog', dependent: :destroy
has_many :dossier_labels, dependent: :destroy
has_many :procedure_labels, through: :dossier_labels
after_destroy_commit :log_destroy

View file

@ -0,0 +1,6 @@
# frozen_string_literal: true
class DossierLabel < ApplicationRecord
belongs_to :dossier
belongs_to :procedure_label
end

View file

@ -2,6 +2,7 @@
class ProcedureLabel < ApplicationRecord
belongs_to :procedure
has_many :dossier_labels, dependent: :destroy
GENERIC_LABELS = [
{ name: 'à relancer', color: 'brown-caramel' },

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
class CreateDossierLabels < ActiveRecord::Migration[7.0]
def change
create_table :dossier_labels do |t|
t.references :dossier, null: false, foreign_key: true
t.references :procedure_label, null: false, foreign_key: true
t.timestamps
end
end
end

View file

@ -416,6 +416,15 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do
t.index ["resolved_at"], name: "index_dossier_corrections_on_resolved_at", where: "((resolved_at IS NULL) OR (resolved_at IS NOT NULL))"
end
create_table "dossier_labels", force: :cascade do |t|
t.datetime "created_at", null: false
t.bigint "dossier_id", null: false
t.bigint "procedure_label_id", null: false
t.datetime "updated_at", null: false
t.index ["dossier_id"], name: "index_dossier_labels_on_dossier_id"
t.index ["procedure_label_id"], name: "index_dossier_labels_on_procedure_label_id"
end
create_table "dossier_operation_logs", force: :cascade do |t|
t.boolean "automatic_operation", default: false, null: false
t.bigint "bill_signature_id"
@ -1289,6 +1298,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do
add_foreign_key "dossier_batch_operations", "dossiers"
add_foreign_key "dossier_corrections", "commentaires"
add_foreign_key "dossier_corrections", "dossiers"
add_foreign_key "dossier_labels", "dossiers"
add_foreign_key "dossier_labels", "procedure_labels"
add_foreign_key "dossier_operation_logs", "bill_signatures"
add_foreign_key "dossier_transfer_logs", "dossiers"
add_foreign_key "dossiers", "batch_operations"