lib/pgsync/client.rb in pgsync-0.4.1 vs lib/pgsync/client.rb in pgsync-0.4.2
- old
+ new
@@ -83,11 +83,12 @@
if opts[:preserve]
raise PgSync::Error, "Cannot use --preserve with --schema-first or --schema-only"
end
log "* Dumping schema"
- sync_schema(source, destination, tables)
+ schema_tables = tables if !opts[:all_schemas] || opts[:tables] || opts[:groups] || args[0] || opts[:exclude]
+ sync_schema(source, destination, schema_tables)
end
unless opts[:schema_only]
confirm_tables_exist(destination, tables, "destination")
@@ -143,13 +144,15 @@
opts[:sql] << " LIMIT #{opts[:limit]}"
deprecated "Use `\"LIMIT #{opts[:limit]}\"` instead"
end
end
- def sync_schema(source, destination, tables)
+ def sync_schema(source, destination, tables = nil)
dump_command = source.dump_command(tables)
restore_command = destination.restore_command
- system("#{dump_command} | #{restore_command}")
+ unless system("#{dump_command} | #{restore_command}")
+ raise PgSync::Error, "Schema sync returned non-zero exit code"
+ end
end
def parse_args(args)
opts = Slop.parse(args) do |o|
o.banner = %{Usage: