mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-23 22:39:00 +01:00
fix RenameTable for PostgreSQL to only use old logic, if we still have an old sequence, and if old logic is used, set sequence value
This commit is contained in:
parent
a862bbb270
commit
2cbd2ded82
@ -371,12 +371,15 @@ class Schema
|
|||||||
{
|
{
|
||||||
if (!($table_def = $this->GetTableDefinition($sOldTableName))) return 0;
|
if (!($table_def = $this->GetTableDefinition($sOldTableName))) return 0;
|
||||||
|
|
||||||
if ($this->_PostgresHasOldSequence($sOldTableName,True) || count($table_def['pk']) ||
|
// only use old PostgreSQL stuff, if we have an old sequence, otherwise rely on it being new enough
|
||||||
count($table_def['ix']) || count($table_def['uc']))
|
if ($this->_PostgresHasOldSequence($sOldTableName,True) &&
|
||||||
|
(count($table_def['pk']) || count($table_def['ix']) || count($table_def['uc'])))
|
||||||
{
|
{
|
||||||
if ($this->adodb->BeginTrans() &&
|
if ($this->adodb->BeginTrans() &&
|
||||||
$this->CreateTable($sNewTableName,$table_def,True) &&
|
$this->CreateTable($sNewTableName,$table_def,True) &&
|
||||||
$this->m_odb->query("INSERT INTO $sNewTableName SELECT * FROM $sOldTableName",__LINE__,__FILE__) &&
|
$this->m_odb->query("INSERT INTO $sNewTableName SELECT * FROM $sOldTableName",__LINE__,__FILE__) &&
|
||||||
|
// sequence must be updated, after inserts containing pkey, otherwise new inserst will fail!
|
||||||
|
(count($table_def['pk']) !== 1 || $this->UpdateSequence($sNewTableName, $table_def['pk'][0])) &&
|
||||||
$this->DropTable($sOldTableName))
|
$this->DropTable($sOldTableName))
|
||||||
{
|
{
|
||||||
$this->adodb->CommitTrans();
|
$this->adodb->CommitTrans();
|
||||||
|
Loading…
Reference in New Issue
Block a user