diff options
author | Bart Visscher <bartv@thisnet.nl> | 2014-01-11 12:23:28 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2014-01-11 12:23:28 +0100 |
commit | af3bedf9858b117b676c915829229fb8745a5e36 (patch) | |
tree | 19002dfc1a05e2558beb543b98e455481af762c3 /core/command | |
parent | 1b7eb4dc6cfce382c7a3192bdc8bf6fd52791de1 (diff) | |
download | nextcloud-server-af3bedf9858b117b676c915829229fb8745a5e36.tar.gz nextcloud-server-af3bedf9858b117b676c915829229fb8745a5e36.zip |
Add option to remove all the tables from the destination database
Diffstat (limited to 'core/command')
-rw-r--r-- | core/command/db/convertfromsqlite.php | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/core/command/db/convertfromsqlite.php b/core/command/db/convertfromsqlite.php index 5ae54b68936..4d5122ca2d7 100644 --- a/core/command/db/convertfromsqlite.php +++ b/core/command/db/convertfromsqlite.php @@ -65,6 +65,12 @@ class ConvertFromSqlite extends Command { InputOption::VALUE_REQUIRED, 'the password of the database to convert to. Will be asked when not specified' ) + ->addOption( + 'clear-schema', + null, + InputOption::VALUE_NONE, + 'remove all tables from the destination database' + ) ; } @@ -124,7 +130,20 @@ class ConvertFromSqlite extends Command { $toDB = \Doctrine\DBAL\DriverManager::getConnection($connectionParams); + // Clearing schema in new database + if ($input->getOption('clear-schema')) { + $schemaManager = $toDB->getSchemaManager(); + $toTables = $schemaManager->listTableNames(); + if (!empty($toTables)) { + $output->writeln('Clearing schema in new database'); + } + foreach($toTables as $table) { + $schemaManager->dropTable($table); + } + } + // create tables in new database + $output->writeln('Creating schema in new database'); $schemaManager = new \OC\DB\MDB2SchemaManager($toDB); $schemaManager->createDbFromStructure(\OC::$SERVERROOT.'/db_structure.xml'); $apps = \OC_App::getEnabledApps(); @@ -188,8 +207,6 @@ class ConvertFromSqlite extends Command { $count = $fromDB->fetchColumn($query); $query = 'SELECT * FROM '.$table; $statement = $fromDB->executeQuery($query); - $query = 'DELETE FROM '.$table; - $toDB->executeUpdate($query); $progress->start($output, $count); $progress->setRedrawFrequency($count > 100 ? 5 : 1); while($row = $statement->fetch()) { |