Skip to content

"artisan migrate:fresh" fails after running "artisan schema:dump" in all but the simplest/default scenario #36054

Closed
@cbj4074

Description

  • Laravel Version: 8.24.0
  • PHP Version: 7.4.11
  • Database Driver & Version: PostgreSQL 12.4

Description:

Currently, Laravel's artisan migrate:fresh command fails after running artisan schema:dump in all but the simplest of scenarios — that is, this process works correctly only when the database contains exactly one schema and its name is public. In any other scenario, exceptions occur.

Steps To Reproduce:

  1. When the connection's search_path contains only one schema, and it is anything other than the default value, public, attempting to run php artisan migrate:fresh after running schema:dump fails (the sole schema is homestead in this example):
  The command "PGPASSWORD=$LARAVEL_LOAD_PASSWORD pg_restore --no-owner --no-acl --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE $LARAVEL_LOAD_PATH" failed.

Exit Code: 1(General error)

Working directory: /home/vagrant/code/laravel

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


Error Output:
================
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3; 2615 2200 SCHEMA homestead postgres
pg_restore: error: could not execute query: ERROR:  schema "homestead" already exists
Command was: CREATE SCHEMA homestead;

(and there are actually 15 additional errors that are ignored on restore, of a similar nature)

  1. Similarly, when the database contains more than one schema (regardless of those specified in the connection's search_path), attempting to run php artisan migrate:fresh fails after running artisan schema:dump, with similar exceptions (relation already exists, multiple primary keys not allowed, etc.).

I'm investigating possible solutions and will post an update or open a PR when ready.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions