diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index cf2c321d8..5ee6bc037 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -261,7 +261,7 @@ class TypeDeChamp < ApplicationRecord end def check_mandatory - if non_fillable? + if non_fillable? || private? self.mandatory = false else true diff --git a/db/migrate/20240619205011_change_types_de_champ_mandatory_default.rb b/db/migrate/20240619205011_change_types_de_champ_mandatory_default.rb new file mode 100644 index 000000000..31a5f2883 --- /dev/null +++ b/db/migrate/20240619205011_change_types_de_champ_mandatory_default.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class ChangeTypesDeChampMandatoryDefault < ActiveRecord::Migration[7.0] + def change + change_column_default :types_de_champ, :mandatory, from: false, to: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 28c317cac..8e70f8121 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[7.0].define(version: 2024_05_27_090508) do +ActiveRecord::Schema[7.0].define(version: 2024_06_19_205011) do # These are extensions that must be enabled in order to support this database enable_extension "pg_buffercache" enable_extension "pg_stat_statements" @@ -1122,7 +1122,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_05_27_090508) do t.datetime "created_at", precision: nil t.text "description" t.string "libelle" - t.boolean "mandatory", default: false + t.boolean "mandatory", default: true t.jsonb "options" t.boolean "private", default: false, null: false t.bigint "stable_id"