add new columns to deleted dossiers

This commit is contained in:
kara Diaby 2020-11-12 10:38:10 +01:00
parent fd766fcf04
commit 06f6cf7771
3 changed files with 25 additions and 9 deletions

View file

@ -2,14 +2,17 @@
#
# Table name: deleted_dossiers
#
# id :bigint not null, primary key
# deleted_at :datetime
# reason :string
# state :string
# created_at :datetime not null
# updated_at :datetime not null
# dossier_id :bigint
# procedure_id :bigint
# id :bigint not null, primary key
# deleted_at :datetime
# reason :string
# state :string
# created_at :datetime not null
# updated_at :datetime not null
# dossier_id :bigint
# groupe_instructeur_id :bigint
# procedure_id :bigint
# revision_id :bigint
# user_id :bigint
#
class DeletedDossier < ApplicationRecord
belongs_to :procedure, -> { with_discarded }, inverse_of: :deleted_dossiers, optional: false
@ -28,6 +31,9 @@ class DeletedDossier < ApplicationRecord
create!(
reason: reasons.fetch(reason),
dossier_id: dossier.id,
groupe_instructeur_id: dossier.groupe_instructeur_id,
revision_id: dossier.revision_id,
user_id: dossier.user_id,
procedure: dossier.procedure,
state: dossier.state,
deleted_at: Time.zone.now

View file

@ -0,0 +1,7 @@
class AddRelationsToDeletedDossiers < ActiveRecord::Migration[6.0]
def change
add_column :deleted_dossiers, :user_id, :bigint
add_column :deleted_dossiers, :groupe_instructeur_id, :bigint
add_column :deleted_dossiers, :revision_id, :bigint
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_11_05_131443) do
ActiveRecord::Schema.define(version: 2020_11_10_155516) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -196,6 +196,9 @@ ActiveRecord::Schema.define(version: 2020_11_05_131443) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "reason"
t.bigint "user_id"
t.bigint "groupe_instructeur_id"
t.bigint "revision_id"
t.index ["procedure_id"], name: "index_deleted_dossiers_on_procedure_id"
end