[Pkg-owncloud-commits] [owncloud] 08/153: Postgresql needs the sequences adjusted after the inserts

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 2638fd47674deaeb630b87f01a46ad94446a2097
Author: Bart Visscher <bartv at thisnet.nl>
Date:   Sat Jan 11 12:25:35 2014 +0100

    Postgresql needs the sequences adjusted after the inserts
---
 core/command/db/convertfromsqlite.php | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/core/command/db/convertfromsqlite.php b/core/command/db/convertfromsqlite.php
index 4d5122c..cd3e494 100644
--- a/core/command/db/convertfromsqlite.php
+++ b/core/command/db/convertfromsqlite.php
@@ -179,6 +179,18 @@ class ConvertFromSqlite extends Command {
 				$output->writeln($table);
 				$this->copyTable($fromDB, $toDB, $table, $output);
 			}
+			if ($type == 'pgsql') {
+				$sequences = $toDB->getSchemaManager()->listSequences();
+				foreach($sequences as $sequence) {
+					$info = $toDB->fetchAssoc('SELECT table_schema, table_name, column_name '
+						.'FROM information_schema.columns '
+						.'WHERE column_default = ? AND table_catalog = ?',
+							array("nextval('".$sequence->getName()."'::regclass)", $dbname));
+					$table_name = $info['table_name'];
+					$column_name = $info['column_name'];
+					$toDB->executeQuery("SELECT setval('" . $sequence->getName() . "', (SELECT MAX(" . $column_name . ") FROM " . $table_name . ")+1)");
+				}
+			}
 			// save new database config
 			$dbhost = $hostname;
 			if ($input->getOption('port')) {

-- 
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