[Pkg-owncloud-commits] [owncloud] 07/153: Add option to remove all the tables from the destination database

David Prévot taffit at moszumanska.debian.org
Tue May 27 03:05:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit af3bedf9858b117b676c915829229fb8745a5e36
Author: Bart Visscher <bartv at thisnet.nl>
Date:   Sat Jan 11 12:23:28 2014 +0100

    Add option to remove all the tables from the destination database
---
 core/command/db/convertfromsqlite.php | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/core/command/db/convertfromsqlite.php b/core/command/db/convertfromsqlite.php
index 5ae54b6..4d5122c 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()) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list