Postgresql needs the sequences adjusted after the inserts
This commit is contained in:
parent
af3bedf985
commit
2638fd4767
1 changed files with 12 additions and 0 deletions
|
@ -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')) {
|
||||
|
|
Loading…
Reference in a new issue