chore(schema): create dossier_corrections
This commit is contained in:
parent
5d245fee7d
commit
2c79ca94f5
8 changed files with 68 additions and 0 deletions
|
@ -19,6 +19,7 @@ class Commentaire < ApplicationRecord
|
|||
|
||||
belongs_to :instructeur, inverse_of: :commentaires, optional: true
|
||||
belongs_to :expert, inverse_of: :commentaires, optional: true
|
||||
has_one :dossier_resolution, inverse_of: :commentaire, dependent: :nullify
|
||||
|
||||
validate :messagerie_available?, on: :create, unless: -> { dossier.brouillon? }
|
||||
|
||||
|
|
7
app/models/concerns/dossier_resolvable_concern.rb
Normal file
7
app/models/concerns/dossier_resolvable_concern.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
module DossierResolvableConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
has_many :resolutions, class_name: 'DossierResolution', dependent: :destroy
|
||||
end
|
||||
end
|
|
@ -50,6 +50,7 @@ class Dossier < ApplicationRecord
|
|||
include DossierFilteringConcern
|
||||
include DossierPrefillableConcern
|
||||
include DossierRebaseConcern
|
||||
include DossierResolvableConcern
|
||||
include DossierSearchableConcern
|
||||
include DossierSectionsConcern
|
||||
include DossierCloneConcern
|
||||
|
|
15
app/models/dossier_resolution.rb
Normal file
15
app/models/dossier_resolution.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: dossier_resolutions
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# resolved_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# commentaire_id :bigint
|
||||
# dossier_id :bigint not null
|
||||
#
|
||||
class DossierResolution < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
belongs_to :commentaire
|
||||
end
|
15
db/migrate/20230228134859_create_dossier_resolutions.rb
Normal file
15
db/migrate/20230228134859_create_dossier_resolutions.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
class CreateDossierCorrections < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
create_table :dossier_corrections do |t|
|
||||
t.references :dossier, null: false, foreign_key: true
|
||||
t.references :commentaire, foreign_key: true
|
||||
t.datetime :resolved_at, precision: 6
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :dossier_corrections, :resolved_at, where: "(resolved_at IS NULL OR resolved_at IS NOT NULL)", algorithm: :concurrently
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -318,6 +318,17 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_08_160551) do
|
|||
t.index ["dossier_id"], name: "index_dossier_batch_operations_on_dossier_id"
|
||||
end
|
||||
|
||||
create_table "dossier_corrections", force: :cascade do |t|
|
||||
t.bigint "commentaire_id"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.bigint "dossier_id", null: false
|
||||
t.datetime "resolved_at", precision: 6
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["commentaire_id"], name: "index_dossier_corrections_on_commentaire_id"
|
||||
t.index ["dossier_id"], name: "index_dossier_corrections_on_dossier_id"
|
||||
t.index ["resolved_at"], name: "index_dossier_corrections_on_resolved_at", where: "((resolved_at IS NULL) OR (resolved_at IS NOT NULL))"
|
||||
end
|
||||
|
||||
create_table "dossier_operation_logs", force: :cascade do |t|
|
||||
t.boolean "automatic_operation", default: false, null: false
|
||||
t.bigint "bill_signature_id"
|
||||
|
@ -1010,6 +1021,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_08_160551) do
|
|||
add_foreign_key "commentaires", "instructeurs"
|
||||
add_foreign_key "dossier_batch_operations", "batch_operations"
|
||||
add_foreign_key "dossier_batch_operations", "dossiers"
|
||||
add_foreign_key "dossier_corrections", "commentaires"
|
||||
add_foreign_key "dossier_corrections", "dossiers"
|
||||
add_foreign_key "dossier_operation_logs", "bill_signatures"
|
||||
add_foreign_key "dossier_transfer_logs", "dossiers"
|
||||
add_foreign_key "dossiers", "batch_operations"
|
||||
|
|
11
spec/factories/dossier_resolutions.rb
Normal file
11
spec/factories/dossier_resolutions.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
FactoryBot.define do
|
||||
factory :dossier_resolution do
|
||||
dossier
|
||||
commentaire
|
||||
resolved_at { nil }
|
||||
|
||||
trait :resolved do
|
||||
resolved_at { Time.zone.now }
|
||||
end
|
||||
end
|
||||
end
|
5
spec/models/dossier_resolution_spec.rb
Normal file
5
spec/models/dossier_resolution_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DossierResolution, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Add table
Reference in a new issue