Updated

db/migrate / 20190514070908_add_signature_count_validated_at_index_to_petitions.rb

A
24 lines of codes
3 methods
1.9 complexity/method
1 churn
5.65 complexity
0 duplications
class AddSignatureCountValidatedAtIndexToPetitions < ActiveRecord::Migration
  1. AddSignatureCountValidatedAtIndexToPetitions has no descriptive comment
disable_ddl_transaction! def up unless index_exists?("index_petitions_on_validated_at_and_signed_at") execute <<-SQL CREATE INDEX CONCURRENTLY index_petitions_on_validated_at_and_signed_at ON petitions USING btree ((last_signed_at > signature_count_validated_at)); SQL end end def down if index_exists?("index_petitions_on_validated_at_and_signed_at") execute "DROP INDEX index_petitions_on_validated_at_and_signed_at;" end end private def index_exists?(name) select_value("SELECT to_regclass('#{name}')") end end