Sha256: e1852ad8609e3e83fea00de9889772dcdd7f9c62e478c401a6d5f19d874d3a3d

Contents?: true

Size: 661 Bytes

Versions: 18

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

18 entries across 18 versions & 1 rubygems

Version Path
pact_broker-2.79.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.79.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.78.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.78.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.77.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.76.2 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.76.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.76.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.75.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.74.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.74.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.73.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.72.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.71.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.70.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.69.0 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.68.1 db/migrations/20201023_create_verification_number_sequence.rb
pact_broker-2.68.0 db/migrations/20201023_create_verification_number_sequence.rb