diff --git a/library/think/console/command/optimize/Schema.php b/library/think/console/command/optimize/Schema.php index 0cc3d3df..a81d6d57 100644 --- a/library/think/console/command/optimize/Schema.php +++ b/library/think/console/command/optimize/Schema.php @@ -24,7 +24,8 @@ class Schema extends Command protected function configure() { $this->setName('optimize:schema') - ->addOption('table', null, Option::VALUE_REQUIRED, 'Build table schema cache .') + ->addOption('db', null, Option::VALUE_REQUIRED, 'db name .') + ->addOption('table', null, Option::VALUE_REQUIRED, 'table name .') ->setDescription('Build database schema cache.'); } @@ -33,18 +34,24 @@ class Schema extends Command if ($input->hasOption('table')) { $tables[] = $input->getOption('table'); } else { - $tables = Db::getTables(); + if ($input->hasOption('db')) { + $dbName = $input->getOption('db'); + $tables = Db::getTables($dbName); + } else { + $tables = Db::getTables(); + } } if (!is_dir(RUNTIME_PATH . 'schema')) { @mkdir(RUNTIME_PATH . 'schema', 0755, true); } + $db = isset($dbName) ? $dbName . '.' : ''; foreach ($tables as $table) { $content = 'writeln('Succeed!');