Sha256: a2aaf63738c9a553b93e5140990c0dabb0b32e42983ef55c39d39c9f2c4145d9

Contents?: true

Size: 633 Bytes

Versions: 44

Compression:

Stored size: 633 Bytes

Contents

require_relative "migration_helper"

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

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

Version data entries

44 entries across 44 versions & 1 rubygems

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