Class: Brillo::Adapter::Postgres
- Defined in:
- lib/brillo/adapter/postgres.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #load_command ⇒ Object
-
#table_footer(klass) ⇒ Object
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.
Methods inherited from Base
#dump_structure_and_migrations, #footer, #header, #initialize
Constructor Details
This class inherits a constructor from Brillo::Adapter::Base
Instance Method Details
#load_command ⇒ Object
4 5 6 7 8 |
# File 'lib/brillo/adapter/postgres.rb', line 4 def load_command host = config[:host] ? "--host #{config[:host]}" : "" password = config[:password] ? "PGPASSWORD=#{config[:password]} " : "" "#{password}psql #{host} -U #{config[:username]} #{config[:database]}" end |
#table_footer(klass) ⇒ Object
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
12 13 14 15 16 17 18 |
# File 'lib/brillo/adapter/postgres.rb', line 12 def (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 |