mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
fix(命令): 忽略备份表以避免在生成方案时包含它们
This commit is contained in:
@@ -32,9 +32,15 @@ class Make extends Command
|
||||
$allTables = Db::getTables();
|
||||
// 过滤掉忽略的表
|
||||
$config = Config::get('scheme.ignore_tables', []);
|
||||
$prefix = Config::get('database.connections.mysql.prefix');
|
||||
$connection = Config::get('database.default', 'mysql');
|
||||
$prefix = Config::get('database.connections.' . $connection . '.prefix', '');
|
||||
$backupPrefix = Config::get('scheme.backup_prefix', 'backup');
|
||||
|
||||
foreach ($allTables as $t) {
|
||||
if ($this->isBackupTable($t, $prefix, $backupPrefix)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 如果有前缀,去除前缀后再判断
|
||||
$shortName = $t;
|
||||
if ($prefix && str_starts_with($t, $prefix)) {
|
||||
@@ -70,4 +76,15 @@ class Make extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function isBackupTable(string $tableName, string $prefix, string $backupPrefix): bool
|
||||
{
|
||||
$basePrefix = $prefix . $backupPrefix;
|
||||
if ($basePrefix === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pattern = '/^' . preg_quote($basePrefix, '/') . '_?\\d{14}(?:_.*)?$/';
|
||||
return preg_match($pattern, $tableName) === 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user