From 55a3d59e38c087502c2ce55e98f75f81fcf1d5d8 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 30 May 2018 11:36:48 +0200 Subject: [PATCH] Create new model to store deleted dossier metadatas --- app/models/deleted_dossier.rb | 3 +++ app/models/procedure.rb | 1 + db/migrate/20180530095508_create_deleted_dossiers.rb | 12 ++++++++++++ db/schema.rb | 12 +++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/models/deleted_dossier.rb create mode 100644 db/migrate/20180530095508_create_deleted_dossiers.rb diff --git a/app/models/deleted_dossier.rb b/app/models/deleted_dossier.rb new file mode 100644 index 000000000..31cffa793 --- /dev/null +++ b/app/models/deleted_dossier.rb @@ -0,0 +1,3 @@ +class DeletedDossier < ApplicationRecord + belongs_to :procedure +end diff --git a/app/models/procedure.rb b/app/models/procedure.rb index a5f06c2a1..b2b5420eb 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -3,6 +3,7 @@ class Procedure < ApplicationRecord has_many :types_de_champ, -> { public_only }, dependent: :destroy has_many :types_de_champ_private, -> { private_only }, class_name: 'TypeDeChamp', dependent: :destroy has_many :dossiers + has_many :deleted_dossiers, dependent: :destroy has_one :module_api_carto, dependent: :destroy has_one :attestation_template, dependent: :destroy diff --git a/db/migrate/20180530095508_create_deleted_dossiers.rb b/db/migrate/20180530095508_create_deleted_dossiers.rb new file mode 100644 index 000000000..9558b23d6 --- /dev/null +++ b/db/migrate/20180530095508_create_deleted_dossiers.rb @@ -0,0 +1,12 @@ +class CreateDeletedDossiers < ActiveRecord::Migration[5.2] + def change + create_table :deleted_dossiers do |t| + t.references :procedure + t.bigint :dossier_id + t.datetime :deleted_at + t.string :state + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 16ea44e85..69ee7bffb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_05_22_142109) do +ActiveRecord::Schema.define(version: 2018_05_30_095508) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -220,6 +220,16 @@ ActiveRecord::Schema.define(version: 2018_05_22_142109) do t.index ["priority", "run_at"], name: "delayed_jobs_priority" end + create_table "deleted_dossiers", force: :cascade do |t| + t.bigint "procedure_id" + t.bigint "dossier_id" + t.datetime "deleted_at" + t.string "state" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["procedure_id"], name: "index_deleted_dossiers_on_procedure_id" + end + create_table "dossiers", id: :serial, force: :cascade do |t| t.boolean "autorisation_donnees" t.integer "procedure_id"