add belongs_to zone for procedure
This commit is contained in:
parent
5b8d872b6e
commit
561f6fb274
4 changed files with 12 additions and 1 deletions
|
@ -48,6 +48,7 @@
|
|||
# parent_procedure_id :bigint
|
||||
# published_revision_id :bigint
|
||||
# service_id :bigint
|
||||
# zone_id :bigint
|
||||
#
|
||||
|
||||
class Procedure < ApplicationRecord
|
||||
|
@ -85,6 +86,7 @@ class Procedure < ApplicationRecord
|
|||
belongs_to :parent_procedure, class_name: 'Procedure', optional: true
|
||||
belongs_to :canonical_procedure, class_name: 'Procedure', optional: true
|
||||
belongs_to :service, optional: true
|
||||
belongs_to :zone, optional: true
|
||||
|
||||
def active_revision
|
||||
brouillon? ? draft_revision : published_revision
|
||||
|
|
5
db/migrate/20211127143736_add_zone_to_procedures.rb
Normal file
5
db/migrate/20211127143736_add_zone_to_procedures.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddZoneToProcedures < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_reference :procedures, :zone, null: true, foreign_key: true
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_11_27_133549) do
|
||||
ActiveRecord::Schema.define(version: 2021_11_27_143736) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -638,6 +638,7 @@ ActiveRecord::Schema.define(version: 2021_11_27_133549) do
|
|||
t.text "api_particulier_scopes", default: [], array: true
|
||||
t.jsonb "api_particulier_sources", default: {}
|
||||
t.boolean "instructeurs_self_management_enabled"
|
||||
t.bigint "zone_id"
|
||||
t.index ["api_particulier_sources"], name: "index_procedures_on_api_particulier_sources", using: :gin
|
||||
t.boolean "routing_enabled"
|
||||
t.index ["declarative_with_state"], name: "index_procedures_on_declarative_with_state"
|
||||
|
@ -648,6 +649,7 @@ ActiveRecord::Schema.define(version: 2021_11_27_133549) do
|
|||
t.index ["path", "closed_at", "hidden_at"], name: "index_procedures_on_path_and_closed_at_and_hidden_at", unique: true
|
||||
t.index ["published_revision_id"], name: "index_procedures_on_published_revision_id"
|
||||
t.index ["service_id"], name: "index_procedures_on_service_id"
|
||||
t.index ["zone_id"], name: "index_procedures_on_zone_id"
|
||||
end
|
||||
|
||||
create_table "received_mails", id: :serial, force: :cascade do |t|
|
||||
|
@ -865,6 +867,7 @@ ActiveRecord::Schema.define(version: 2021_11_27_133549) do
|
|||
add_foreign_key "procedures", "procedure_revisions", column: "draft_revision_id"
|
||||
add_foreign_key "procedures", "procedure_revisions", column: "published_revision_id"
|
||||
add_foreign_key "procedures", "services"
|
||||
add_foreign_key "procedures", "zones"
|
||||
add_foreign_key "received_mails", "procedures"
|
||||
add_foreign_key "refused_mails", "procedures"
|
||||
add_foreign_key "services", "administrateurs"
|
||||
|
|
|
@ -12,6 +12,7 @@ FactoryBot.define do
|
|||
ask_birthday { false }
|
||||
lien_site_web { "https://mon-site.gouv" }
|
||||
path { SecureRandom.uuid }
|
||||
association :zone
|
||||
|
||||
groupe_instructeurs { [association(:groupe_instructeur, :default, procedure: instance, strategy: :build)] }
|
||||
administrateurs { administrateur.present? ? [administrateur] : [association(:administrateur)] }
|
||||
|
|
Loading…
Reference in a new issue