db: add uniqueness constraints to Champs
This commit is contained in:
parent
0fd23ebd43
commit
3d25fc995a
2 changed files with 16 additions and 1 deletions
14
db/migrate/20210722133440_add_unique_index_to_champs.rb
Normal file
14
db/migrate/20210722133440_add_unique_index_to_champs.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class AddUniqueIndexToChamps < ActiveRecord::Migration[6.1]
|
||||
include Database::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
delete_duplicates :champs, [:type_de_champ_id, :dossier_id, :row]
|
||||
add_concurrent_index :champs, [:type_de_champ_id, :dossier_id, :row], unique: true
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :champs, [:type_de_champ_id, :dossier_id, :row]
|
||||
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_06_04_095054) do
|
||||
ActiveRecord::Schema.define(version: 2021_07_22_133440) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -174,6 +174,7 @@ ActiveRecord::Schema.define(version: 2021_06_04_095054) do
|
|||
t.index ["parent_id"], name: "index_champs_on_parent_id"
|
||||
t.index ["private"], name: "index_champs_on_private"
|
||||
t.index ["row"], name: "index_champs_on_row"
|
||||
t.index ["type_de_champ_id", "dossier_id", "row"], name: "index_champs_on_type_de_champ_id_and_dossier_id_and_row", unique: true
|
||||
t.index ["type_de_champ_id"], name: "index_champs_on_type_de_champ_id"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue