Add reason to DeletedDossier

# Conflicts:
#	db/schema.rb
This commit is contained in:
Paul Chavard 2020-03-19 11:51:47 +01:00
parent b2706b9031
commit 9243ae69df
3 changed files with 22 additions and 3 deletions

View file

@ -1,7 +1,20 @@
class DeletedDossier < ApplicationRecord
belongs_to :procedure
def self.create_from_dossier(dossier)
DeletedDossier.create!(dossier_id: dossier.id, procedure: dossier.procedure, state: dossier.state, deleted_at: Time.zone.now)
enum reason: {
user_request: 'user_request',
manager_request: 'manager_request',
user_removed: 'user_removed',
expired: 'expired'
}
def self.create_from_dossier(dossier, reason)
create!(
reason: reasons.fetch(reason),
dossier_id: dossier.id,
procedure: dossier.procedure,
state: dossier.state,
deleted_at: Time.zone.now
)
end
end

View file

@ -0,0 +1,5 @@
class AddReasonToDeletedDossiers < ActiveRecord::Migration[5.2]
def change
add_column :deleted_dossiers, :reason, :string
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_03_04_155418) do
ActiveRecord::Schema.define(version: 2020_03_19_103836) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -213,6 +213,7 @@ ActiveRecord::Schema.define(version: 2020_03_04_155418) do
t.string "state"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "reason"
t.index ["procedure_id"], name: "index_deleted_dossiers_on_procedure_id"
end