ankane/pgsync · error · Error

Cannot use --preserve with --schema-first or --schema-only

Error message

Cannot use --preserve with --schema-first or --schema-only

What it means

Error "Cannot use --preserve with --schema-first or --schema-only" thrown in ankane/pgsync.

Source

Thrown at lib/pgsync/schema_sync.rb:17

module PgSync
  class SchemaSync
    include Utils

    attr_reader :args, :opts

    def initialize(source:, destination:, tasks:, args:, opts:)
      @source = source
      @destination = destination
      @tasks = tasks
      @args = args
      @opts = opts
    end

    def perform
      if opts[:preserve]
        raise Error, "Cannot use --preserve with --schema-first or --schema-only"
      end

      # generate commands before starting spinner
      # for better error output if pg_restore not found
      dump_command = dump_command()
      restore_command = restore_command()

      show_spinner = output.tty? && !opts[:debug]

      if show_spinner
        spinner = TTY::Spinner.new(":spinner Syncing schema", format: :dots)
        spinner.auto_spin
      end

      create_schemas if specify_tables?

      # if spinner, capture lines to show on error
      lines = []

View on GitHub (pinned to 57bdddf5db)

When it happens

Trigger: Thrown at lib/pgsync/schema_sync.rb:17 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ankane/pgsync@57bdddf5db (2026-08-23). Data as JSON: /api/errors/5ff7dbe5721cb6e7. Report an issue: GitHub.