Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rez1dent3 opened this issue Feb 26, 2025 · 3 comments · Fixed by #54834
Closed

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

rez1dent3 opened this issue Feb 26, 2025 · 3 comments · Fixed by #54834

Comments

@rez1dent3
Copy link
Contributor

rez1dent3 commented Feb 26, 2025

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;
@rez1dent3
Copy link
Contributor Author

Laravel 12 code does not take into account Schema::dropIfExists. Therefore, it is better to add if exists directly in hardcode.

@rez1dent3
Copy link
Contributor Author

I temporarily solved my problem by removing the prefix in mysql/mariadb tests.
bavix/laravel-wallet@19bd091

I hope you fix it and I can get this code back. Many users used prefix for tenant packages.

@hafezdivandari
Copy link
Contributor

Just sent PR #54834 to resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants