fixed:migration 表前缀

This commit is contained in:
JaguarJack 2020-07-27 07:58:11 +08:00
parent cc34e058f0
commit cba66dfe58

View File

@ -3,6 +3,7 @@ namespace catcher\generate\factory;
use catcher\CatchAdmin;
use catcher\exceptions\FailedException;
use catcher\Utils;
use JaguarJack\MigrateGenerator\MigrateGenerator;
use think\facade\Db;
use think\helper\Str;
@ -30,7 +31,11 @@ class Migration extends Factory
foreach ($tables as $table) {
if ($table->getName() == $tableName) {
file_put_contents($file, $migrateGenerator->getMigrationContent($table));
$content = $migrateGenerator->getMigrationContent($table);
$noPrefix = str_replace(Utils::tablePrefix(), '', $tableName);
$_content = str_replace($tableName, $noPrefix, $content, $count);
file_put_contents($file, $count == 1 ? $_content : $content);
if (!file_exists($file)) {
throw new FailedException('migration generate failed');
}