diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 1d87dd735..1d54e6cf8 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -60,6 +60,7 @@ class Procedure < ApplicationRecord has_and_belongs_to_many :procedure_tags has_many :bulk_messages, dependent: :destroy + has_many :procedure_labels, dependent: :destroy def active_dossier_submitted_message published_dossier_submitted_message || draft_dossier_submitted_message diff --git a/app/models/procedure_label.rb b/app/models/procedure_label.rb new file mode 100644 index 000000000..27ce139ef --- /dev/null +++ b/app/models/procedure_label.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class ProcedureLabel < ApplicationRecord + belongs_to :procedure + + validates :name, :color, presence: true +end diff --git a/db/migrate/20240924151336_create_procedure_labels.rb b/db/migrate/20240924151336_create_procedure_labels.rb new file mode 100644 index 000000000..0d916fd25 --- /dev/null +++ b/db/migrate/20240924151336_create_procedure_labels.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +class CreateProcedureLabels < ActiveRecord::Migration[7.0] + def change + create_table :procedure_labels do |t| + t.string :name + t.string :color + t.references :procedure, null: false, foreign_key: true + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 93aea3e2b..d61271b55 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -869,6 +869,15 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do t.index ["from"], name: "index_path_rewrites_on_from", unique: true end + create_table "procedure_labels", force: :cascade do |t| + t.string "color" + t.datetime "created_at", null: false + t.string "name" + t.bigint "procedure_id", null: false + t.datetime "updated_at", null: false + t.index ["procedure_id"], name: "index_procedure_labels_on_procedure_id" + end + create_table "procedure_presentations", id: :serial, force: :cascade do |t| t.jsonb "a_suivre_filters", default: [], null: false, array: true t.jsonb "archives_filters", default: [], null: false, array: true @@ -1301,6 +1310,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do add_foreign_key "initiated_mails", "procedures" add_foreign_key "instructeurs", "users" add_foreign_key "merge_logs", "users" + add_foreign_key "procedure_labels", "procedures" add_foreign_key "procedure_presentations", "assign_tos" add_foreign_key "procedure_revision_types_de_champ", "procedure_revision_types_de_champ", column: "parent_id" add_foreign_key "procedure_revision_types_de_champ", "procedure_revisions", column: "revision_id"