diff options
author | Joas Schilling <coding@schilljs.com> | 2017-07-18 13:37:01 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-07-25 12:45:38 +0200 |
commit | f6c48b1548763e0eda66af7c2720d363e1671090 (patch) | |
tree | d3ae4f2a405d08c4e052e7beabb06e3609b7423e /core/Command/Db/Migrations/GenerateCommand.php | |
parent | 8d751ff2b429380af7e5c870844a6a32f82f0741 (diff) | |
download | nextcloud-server-f6c48b1548763e0eda66af7c2720d363e1671090.tar.gz nextcloud-server-f6c48b1548763e0eda66af7c2720d363e1671090.zip |
Add a script to generate a migration from database.xml
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command/Db/Migrations/GenerateCommand.php')
-rw-r--r-- | core/Command/Db/Migrations/GenerateCommand.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/core/Command/Db/Migrations/GenerateCommand.php b/core/Command/Db/Migrations/GenerateCommand.php index e6c38d06e5d..f8a992940f9 100644 --- a/core/Command/Db/Migrations/GenerateCommand.php +++ b/core/Command/Db/Migrations/GenerateCommand.php @@ -36,7 +36,7 @@ use Symfony\Component\Console\Output\OutputInterface; class GenerateCommand extends Command { - private static $_templateSimple = + protected static $_templateSimple = '<?php namespace <namespace>; @@ -66,7 +66,7 @@ class <classname> extends SimpleMigrationStep { * @since 13.0.0 */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { - return null; +<schemabody> } /** @@ -81,7 +81,7 @@ class <classname> extends SimpleMigrationStep { '; /** @var IDBConnection */ - private $connection; + protected $connection; /** * @param IDBConnection $connection @@ -123,16 +123,24 @@ class <classname> extends SimpleMigrationStep { /** * @param MigrationService $ms * @param string $className + * @param string $schemaBody * @return string */ - private function generateMigration(MigrationService $ms, $className) { + protected function generateMigration(MigrationService $ms, $className, $schemaBody = '') { + if ($schemaBody === '') { + $schemaBody = "\t\t" . 'return null;'; + } + + $placeHolders = [ '<namespace>', '<classname>', + '<schemabody>', ]; $replacements = [ $ms->getMigrationsNamespace(), $className, + $schemaBody, ]; $code = str_replace($placeHolders, $replacements, self::$_templateSimple); $dir = $ms->getMigrationsDirectory(); @@ -147,7 +155,7 @@ class <classname> extends SimpleMigrationStep { return $path; } - private function ensureMigrationDirExists($directory) { + protected function ensureMigrationDirExists($directory) { if (file_exists($directory) && is_dir($directory)) { return; } |