Sha256: e9686d895ebe58a71a805099d53f6500a46eebf4d85316db677ecc56f8114283

Contents?: true

Size: 728 Bytes

Versions: 3

Compression:

Stored size: 728 Bytes

Contents

module Brillo
  module Adapter
    class Postgres < Base
      def load_command
        host = config[:host] ? "--host #{config[:host]}" : ""
        password = config[:password] ? "-W#{config[:password]}" : ""
        "psql #{host} -U #{config[:username]} #{password} #{config[:database]}"
      end

      # pgdump without schema does not set sequences, so we have to do it ourselves, or the first insert
      # into a scrubbed table will fail on duplicate primary key
      def table_footer(klass)
        table_name = klass.table_name
        <<-SQL
          SELECT setval(pg_get_serial_sequence('#{table_name}', 'id'), coalesce(MAX(id),0) + 1, false)
          FROM #{table_name};
        SQL
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brillo-1.1.3 lib/brillo/adapter/postgres.rb
brillo-1.1.2 lib/brillo/adapter/postgres.rb
brillo-1.1.1 lib/brillo/adapter/postgres.rb