Sha256: 4ddde8dcb9439224ba8287316f99ea58b97560296f92c436bf6c904510fde789

Contents?: true

Size: 737 Bytes

Versions: 5

Compression:

Stored size: 737 Bytes

Contents

module Brillo
  module Adapter
    class Postgres < Base
      def load_command
        host = config[:host] ? "--host #{config[:host]}" : ""
        password = config[:password] ? "PGPASSWORD=#{config[:password]} " : ""
        "#{password}psql #{host} -U #{config[:username]} #{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

5 entries across 5 versions & 1 rubygems

Version Path
brillo-1.2.2 lib/brillo/adapter/postgres.rb
brillo-1.2.1 lib/brillo/adapter/postgres.rb
brillo-1.2.0 lib/brillo/adapter/postgres.rb
brillo-1.1.4 lib/brillo/adapter/postgres.rb
brillo-1.1.4.pre2 lib/brillo/adapter/postgres.rb