laravel-schematics icon indicating copy to clipboard operation
laravel-schematics copied to clipboard

Table prefix issue

Open SabatinoMasala opened this issue 4 years ago • 1 comments

The table name returned by $model->getTable() is unprefixed, causing errors on the describe query if a table prefix is present.

https://github.com/mtolhuys/laravel-schematics/blob/c69a2e85687443c691ed8bd79d88d2f61eafc0b1/src/Http/Controllers/ModelsController.php#L59

https://github.com/mtolhuys/laravel-schematics/blob/c69a2e85687443c691ed8bd79d88d2f61eafc0b1/src/Http/Controllers/ModelsController.php#L60

This could be solved by adding the prefix manually:

$safeTableName = \DB::getQueryGrammar()->wrap($model->getConnection()->getTablePrefix() . $table);

I had this issue occur on an older Laravel version: 5.7

Not tested on anything newer.

SabatinoMasala avatar Apr 04 '20 09:04 SabatinoMasala

Hi @SabatinoMasala,

Thnx for the suggestion! I'll try it out in my environments and take it along with the next release.

mtolhuys avatar Apr 07 '20 08:04 mtolhuys