demarches-normaliennes/db/migrate/20240522084927_add_attestation_template_unicity_index.rb
2024-06-20 11:08:15 +02:00

12 lines
536 B
Ruby

class AddAttestationTemplateUnicityIndex < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
# this index was not created on production
if index_exists?(:attestation_templates, [:procedure_id, :version])
remove_index :attestation_templates, [:procedure_id, :version], unique: true, algorithm: :concurrently
end
add_index :attestation_templates, [:procedure_id, :version, :state], name: "index_attestation_templates_on_procedure_version_state", unique: true, algorithm: :concurrently
end
end