Merge pull request #6136 from betagouv/add-some-unique-contraints
Ajout de contraintes d'unicité sur les tables Invites, Procedures et Individuals (#6136)
This commit is contained in:
commit
02902e2b0e
5 changed files with 86 additions and 42 deletions
|
@ -19,8 +19,8 @@
|
||||||
# duree_conservation_dossiers_hors_ds :integer
|
# duree_conservation_dossiers_hors_ds :integer
|
||||||
# durees_conservation_required :boolean default(TRUE)
|
# durees_conservation_required :boolean default(TRUE)
|
||||||
# euro_flag :boolean default(FALSE)
|
# euro_flag :boolean default(FALSE)
|
||||||
# for_individual :boolean default(FALSE)
|
|
||||||
# experts_require_administrateur_invitation :boolean default(FALSE)
|
# experts_require_administrateur_invitation :boolean default(FALSE)
|
||||||
|
# for_individual :boolean default(FALSE)
|
||||||
# hidden_at :datetime
|
# hidden_at :datetime
|
||||||
# juridique_required :boolean default(TRUE)
|
# juridique_required :boolean default(TRUE)
|
||||||
# libelle :string
|
# libelle :string
|
||||||
|
|
14
db/migrate/20210427120000_add_unique_index_to_invites.rb
Normal file
14
db/migrate/20210427120000_add_unique_index_to_invites.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class AddUniqueIndexToInvites < ActiveRecord::Migration[6.1]
|
||||||
|
include Database::MigrationHelpers
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
delete_duplicates :invites, [:email, :dossier_id]
|
||||||
|
add_concurrent_index :invites, [:email, :dossier_id], unique: true
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_index :invites, column: [:email, :dossier_id]
|
||||||
|
end
|
||||||
|
end
|
14
db/migrate/20210427120001_add_unique_index_to_procedures.rb
Normal file
14
db/migrate/20210427120001_add_unique_index_to_procedures.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class AddUniqueIndexToProcedures < ActiveRecord::Migration[6.1]
|
||||||
|
include Database::MigrationHelpers
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
delete_duplicates :procedures, [:path, :closed_at, :hidden_at, :unpublished_at]
|
||||||
|
add_concurrent_index :procedures, [:path, :closed_at, :hidden_at, :unpublished_at], name: 'procedure_path_uniqueness', unique: true
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_index :procedures, [:path, :closed_at, :hidden_at, :unpublished_at], name: 'procedure_path_uniqueness'
|
||||||
|
end
|
||||||
|
end
|
14
db/migrate/20210427120002_add_unique_index_to_individuals.rb
Normal file
14
db/migrate/20210427120002_add_unique_index_to_individuals.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
class AddUniqueIndexToIndividuals < ActiveRecord::Migration[6.1]
|
||||||
|
include Database::MigrationHelpers
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
delete_duplicates :individuals, [:dossier_id]
|
||||||
|
add_concurrent_index :individuals, [:dossier_id], unique: true
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_index :individuals, [:dossier_id]
|
||||||
|
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: 2021_04_22_101149) do
|
ActiveRecord::Schema.define(version: 2021_04_27_120002) 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"
|
||||||
|
@ -446,7 +446,7 @@ ActiveRecord::Schema.define(version: 2021_04_22_101149) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.date "birthdate"
|
t.date "birthdate"
|
||||||
t.index ["dossier_id"], name: "index_individuals_on_dossier_id"
|
t.index ["dossier_id"], name: "index_individuals_on_dossier_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "initiated_mails", id: :serial, force: :cascade do |t|
|
create_table "initiated_mails", id: :serial, force: :cascade do |t|
|
||||||
|
@ -474,6 +474,7 @@ ActiveRecord::Schema.define(version: 2021_04_22_101149) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.text "message"
|
t.text "message"
|
||||||
|
t.index ["email", "dossier_id"], name: "index_invites_on_email_and_dossier_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "module_api_cartos", id: :serial, force: :cascade do |t|
|
create_table "module_api_cartos", id: :serial, force: :cascade do |t|
|
||||||
|
@ -559,6 +560,7 @@ ActiveRecord::Schema.define(version: 2021_04_22_101149) do
|
||||||
t.index ["draft_revision_id"], name: "index_procedures_on_draft_revision_id"
|
t.index ["draft_revision_id"], name: "index_procedures_on_draft_revision_id"
|
||||||
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", "closed_at", "hidden_at", "unpublished_at"], name: "procedure_path_uniqueness", unique: true
|
||||||
t.index ["path", "closed_at", "hidden_at"], name: "index_procedures_on_path_and_closed_at_and_hidden_at", unique: true
|
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 ["published_revision_id"], name: "index_procedures_on_published_revision_id"
|
||||||
t.index ["service_id"], name: "index_procedures_on_service_id"
|
t.index ["service_id"], name: "index_procedures_on_service_id"
|
||||||
|
|
Loading…
Reference in a new issue