Migration: Index and make Procedure.path nonnull
This commit is contained in:
parent
703c436c61
commit
e9c6ed80e4
4 changed files with 11 additions and 3 deletions
|
@ -66,7 +66,7 @@ class Procedure < ApplicationRecord
|
||||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||||
validates :administrateurs, presence: true
|
validates :administrateurs, presence: true
|
||||||
validate :check_juridique
|
validate :check_juridique
|
||||||
validates :path, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: { scope: :aasm_state, case_sensitive: false }, presence: true, allow_blank: false, allow_nil: true
|
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,50}\z/ }, uniqueness: { scope: [:path, :archived_at, :hidden_at], case_sensitive: false }
|
||||||
# FIXME: remove duree_conservation_required flag once all procedures are converted to the new style
|
# FIXME: remove duree_conservation_required flag once all procedures are converted to the new style
|
||||||
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }, if: :durees_conservation_required
|
validates :duree_conservation_dossiers_dans_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: MAX_DUREE_CONSERVATION }, if: :durees_conservation_required
|
||||||
validates :duree_conservation_dossiers_hors_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :durees_conservation_required
|
validates :duree_conservation_dossiers_hors_ds, allow_nil: false, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :durees_conservation_required
|
||||||
|
|
6
db/migrate/20190917151652_make_path_nonnull.rb
Normal file
6
db/migrate/20190917151652_make_path_nonnull.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class MakePathNonnull < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
change_column_null :procedures, :path, false
|
||||||
|
add_index :procedures, [:path, :archived_at, :hidden_at], unique: true
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2019_09_17_120856) do
|
ActiveRecord::Schema.define(version: 2019_09_17_151652) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -480,12 +480,13 @@ ActiveRecord::Schema.define(version: 2019_09_17_120856) do
|
||||||
t.string "cadre_juridique"
|
t.string "cadre_juridique"
|
||||||
t.boolean "juridique_required", default: true
|
t.boolean "juridique_required", default: true
|
||||||
t.boolean "durees_conservation_required", default: true
|
t.boolean "durees_conservation_required", default: true
|
||||||
t.string "path"
|
t.string "path", null: false
|
||||||
t.string "declarative_with_state"
|
t.string "declarative_with_state"
|
||||||
t.text "monavis_embed"
|
t.text "monavis_embed"
|
||||||
t.index ["declarative_with_state"], name: "index_procedures_on_declarative_with_state"
|
t.index ["declarative_with_state"], name: "index_procedures_on_declarative_with_state"
|
||||||
t.index ["hidden_at"], name: "index_procedures_on_hidden_at"
|
t.index ["hidden_at"], name: "index_procedures_on_hidden_at"
|
||||||
t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id"
|
t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id"
|
||||||
|
t.index ["path", "archived_at", "hidden_at"], name: "index_procedures_on_path_and_archived_at_and_hidden_at", unique: true
|
||||||
t.index ["service_id"], name: "index_procedures_on_service_id"
|
t.index ["service_id"], name: "index_procedures_on_service_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ FactoryBot.define do
|
||||||
duree_conservation_dossiers_hors_ds { 6 }
|
duree_conservation_dossiers_hors_ds { 6 }
|
||||||
ask_birthday { false }
|
ask_birthday { false }
|
||||||
lien_site_web { "https://mon-site.gouv" }
|
lien_site_web { "https://mon-site.gouv" }
|
||||||
|
path { SecureRandom.uuid }
|
||||||
|
|
||||||
transient do
|
transient do
|
||||||
administrateur {}
|
administrateur {}
|
||||||
|
|
Loading…
Reference in a new issue