From 222459f517f334c0dd59710ef3c312aa9cf4d1a3 Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Wed, 2 Sep 2009 20:35:30 +0000 Subject: [PATCH] [2.0] Fixed issue with RunSqlTask. Added basic support to --update in SchemaToolTask. Misses some internal implementation --- lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php | 5 +++-- lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php b/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php index b644fb983..623b44b6b 100644 --- a/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php +++ b/lib/Doctrine/ORM/Tools/Cli/Tasks/RunSqlTask.php @@ -41,7 +41,7 @@ class RunSqlTask extends AbstractTask private function _writeSynopsis($printer) { $printer->write('run-sql', 'KEYWORD') - ->writeln(' --file= | --sql=', 'INFO'); + ->writeln(' (--file= | --sql=)', 'INFO'); } /** @@ -53,7 +53,8 @@ class RunSqlTask extends AbstractTask return false; } - $args= $this->getArguments(); + $args = $this->getArguments(); + $printer = $this->getPrinter(); $isSql = isset($args['sql']); $isFile = isset($args['file']); diff --git a/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php b/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php index 8fc2f8311..ee8558aa4 100644 --- a/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php +++ b/lib/Doctrine/ORM/Tools/Cli/Tasks/SchemaToolTask.php @@ -143,7 +143,7 @@ class SchemaToolTask extends AbstractTask } else { $printer->writeln('Creating database schema...', 'INFO'); $tool->createSchema($classes); - $printer->write('Database schema created successfully.' . PHP_EOL, 'INFO'); + $printer->writeln('Database schema created successfully.', 'INFO'); } } else if ($isDrop) { if (isset($args['dump-sql'])) { @@ -156,8 +156,15 @@ class SchemaToolTask extends AbstractTask $printer->writeln('Database schema dropped successfully.', 'INFO'); } } else if ($isUpdate) { - //TODO - $printer->writeln('--update not yet implemented.', 'COMMENT'); + if (isset($args['dump-sql'])) { + foreach ($tool->getUpdateSchemaSql($classes) as $sql) { + $printer->writeln($sql); + } + } else { + $printer->writeln('Updating database schema...', 'INFO'); + $tool->updateSchema($classes); + $printer->writeln('Database schema updated successfully.', 'INFO'); + } } } } \ No newline at end of file