add export_template to exports

This commit is contained in:
Christophe Robillard 2024-03-08 10:11:11 +01:00 committed by simon lehericey
parent a12d6b4af0
commit 7661b8b1b2
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
5 changed files with 20 additions and 0 deletions

View file

@ -31,6 +31,7 @@ class Export < ApplicationRecord
belongs_to :procedure_presentation, optional: true
belongs_to :instructeur, optional: true
belongs_to :user_profile, polymorphic: true, optional: true
belongs_to :export_template, optional: true
has_one_attached :file

View file

@ -0,0 +1,6 @@
class AddTemplateToExports < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
add_reference :exports, :export_template, null: true, index: { algorithm: :concurrently }
end
end

View file

@ -0,0 +1,5 @@
class AddExportTemplateFk < ActiveRecord::Migration[7.0]
def change
add_foreign_key :exports, :export_templates, validate: false
end
end

View file

@ -0,0 +1,5 @@
class ValidateExportTemplateFk < ActiveRecord::Migration[7.0]
def change
validate_foreign_key :exports, :export_templates
end
end

View file

@ -606,6 +606,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_17_053843) do
create_table "exports", force: :cascade do |t|
t.datetime "created_at", precision: nil, null: false
t.integer "dossiers_count"
t.bigint "export_template_id"
t.string "format", null: false
t.bigint "instructeur_id"
t.string "job_status", default: "pending", null: false
@ -617,6 +618,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_17_053843) do
t.datetime "updated_at", precision: nil, null: false
t.bigint "user_profile_id"
t.string "user_profile_type"
t.index ["export_template_id"], name: "index_exports_on_export_template_id"
t.index ["instructeur_id"], name: "index_exports_on_instructeur_id"
t.index ["key"], name: "index_exports_on_key"
t.index ["procedure_presentation_id"], name: "index_exports_on_procedure_presentation_id"
@ -1235,6 +1237,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_17_053843) do
add_foreign_key "experts_procedures", "experts"
add_foreign_key "experts_procedures", "procedures"
add_foreign_key "export_templates", "groupe_instructeurs"
add_foreign_key "exports", "export_templates"
add_foreign_key "exports", "instructeurs"
add_foreign_key "france_connect_informations", "users"
add_foreign_key "geo_areas", "champs"