Sha256: 51a2b82f753d5eecf9cf747bdf773acc0dd393356a8883fce66cba1c7028f287

Contents?: true

Size: 661 Bytes

Versions: 44

Compression:

Stored size: 661 Bytes

Contents

require_relative "migration_helper"

Sequel.migration do
  up do
    if PactBroker::MigrationHelper.postgres?
      row = from(:verification_sequence_number).select(:value).limit(1).first
      start = row ? row[:value] + 100 : 1
      run("CREATE SEQUENCE verification_number_sequence START WITH #{start}")
    end
  end

  down do
    if PactBroker::MigrationHelper.postgres?
      nextval = execute("SELECT nextval('verification_number_sequence') as val") { |v| v.first["val"].to_i }
      # Add a safety margin!
      from(:verification_sequence_number).update(value: nextval + 100)
      run("DROP SEQUENCE verification_number_sequence")
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
pact_broker-2.112.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.111.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.109.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.109.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.108.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.107.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.107.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.107.0.beta.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.106.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.105.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.104.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.103.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.102.2 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.102.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.102.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.101.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.100.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.99.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.98.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.97.0 db/migrations/20201023_create_verification_number_sequence.rb