Skip to content

[12.x] Adding a prefix to the database name in MySQL/MariaDB #54817

Closed
@rez1dent3

Description

@rez1dent3

Laravel Version

12.0.1

PHP Version

any

Database Driver & Version

MySQL/MariaDB

Description

Hello.

I decided to add laravel 12 support to my package, but now the prefix ONLY for MySQL/MariaDB builders is added to the database name. On postgres, sqlite everything is ok.

Describe the bug

Methods like these use wrapArray, which adds a prefix to the string.

    public function compileDropAllTables($tables)
    {
        return 'drop table '.implode(',', $this->wrapArray($tables));
    }

When I replaced the code with this one, the problem went away immediately.

    public function compileDropAllTables($tables)
    {
        return 'drop table '.implode(',', array_map($this->wrapTable(...), $tables));
    }

Expected behavior

- drop table `testswallet`.`testscache`,`testswallet`.`testscache_locks`,`testswallet`.`testsitems`,`testswallet`.`testsmanagers`,`testswallet`.`testsmigrations`,`testswallet`.`teststransaction`,`testswallet`.`teststransfer`,`testswallet`.`testsusers`,`testswallet`.`testswallet`)
+ drop table `wallet`.`testscache`,`wallet`.`testscache_locks`,`wallet`.`testsitems`,`wallet`.`testsmanagers`,`wallet`.`testsmigrations`,`wallet`.`teststransaction`,`wallet`.`teststransfer`,`wallet`.`testsusers`,`wallet`.`testswallet`)

postgres: https://github.com/bavix/laravel-wallet/actions/runs/13506555515/job/37870925893
mariadb: https://github.com/bavix/laravel-wallet/actions/runs/13506555515/job/37870935563
mysql: https://github.com/bavix/laravel-wallet/actions/runs/13506555515/job/37870930173
sqlite: https://github.com/bavix/laravel-wallet/actions/runs/13506555515/job/37870921408

The problem appeared here: #54487

Steps To Reproduce

  1. Add a prefix to the connection settings;
  2. Start dropping all tables;

Metadata

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