Skip to content

[10.x] schema:dump command attempts to dump migrations table on non default connection #51813

@NickSdot

Description

@NickSdot

Laravel Version

10.48.12

PHP Version

8.2

Database Driver & Version

MySql Ver 8.3.0 for macos14.4 on arm64 (Homebrew)

Description

The DumpCommand allows to be run with the database flag: php artisan schema:dump --database=geo

Doing so on a non-default connection results in:

Symfony\Component\Process\Exception\ProcessFailedException 

The command "mysqldump  --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc "${:LARAVEL_LOAD_DATABASE}" migrations --no-create-info --skip-extended-insert --skip-routines --compact --complete-insert" failed.

Exit Code: 6(Unknown error)

Working directory: /Users/Nick/Projects/blub

Output:
================


Error Output:
================
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Couldn't find table: "migrations"

  at /Users/Nick/.composer/vendor/symfony/process/Process.php:267
    263▕      */
    264▕     public function mustRun(?callable $callback = null, array $env = []): static
    265▕     {
    266▕         if (0 !== $this->run($callback, $env)) {
  ➜ 267▕             throw new ProcessFailedException($this);
    268▕         }
    269▕ 
    270▕         return $this;
    271▕     }

      +18 vendor frames 

  19  artisan:46
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

This is because the migrations table is only available on the default connection.
It's an easy fix. But there is two sensible ways.

Question

Before submitting a PR, is my assumption correct that the migrations table should/must only exist on the default connection?

Potential Fixes

Depending on the answer to the question above I'd propose to fix it as below.

If yes:

  • attempt to append the migrations only when the connection is the default

If no:

  • attempt to append the migrations only when the table exists

Steps To Reproduce

Run php artisan schema:dump --database=SomeConnection on a non default connection.

Lmk if you need a reproduction.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions