From abf980a58706c54b0daa4ae119ab26b3d70756c3 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 1 Oct 2006 08:44:55 +0000 Subject: [PATCH] Now table renaming is working properly on PostgreSQL (only renaming of check constraints are pending) --- .../generators/postgres7/postgres7.class.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/xmldb/classes/generators/postgres7/postgres7.class.php b/lib/xmldb/classes/generators/postgres7/postgres7.class.php index 0ec062cbe2..7a1e3e68fb 100644 --- a/lib/xmldb/classes/generators/postgres7/postgres7.class.php +++ b/lib/xmldb/classes/generators/postgres7/postgres7.class.php @@ -41,6 +41,8 @@ class XMLDBpostgres7 extends XMLDBgenerator { var $sequence_name = 'BIGSERIAL'; //Particular name for inline sequences in this generator var $sequence_only = true; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name variable + var $rename_table_extra_code = true; //Does the generator need to add code after table rename + var $enum_inline_code = false; //Does the generator need to add inline code in the column definition var $rename_key_sql = null; //SQL sentence to rename one key (PostgreSQL doesn't support this!) @@ -133,6 +135,26 @@ class XMLDBpostgres7 extends XMLDBgenerator { return array($comment); } + /** + * Returns the code (array of statements) needed to execute extra statements on table rename + */ + function getRenameTableExtraSQL ($xmldb_table, $newname) { + + $results = array(); + + $newt = new XMLDBTable($newname); + + $xmldb_field = new XMLDBField('id'); // Fields having sequences should be exclusively, id. + + $oldseqname = $this->getTableName($xmldb_table) . '_' . $xmldb_field->getName() . '_seq'; + $newseqname = $this->getTableName($newt) . '_' . $xmldb_field->getName() . '_seq'; + + /// Rename de sequence + $results[] = 'ALTER TABLE ' . $oldseqname . ' RENAME TO ' . $newseqname; + + return $results; + } + /** * Given one XMLDBTable and one XMLDBField, return the SQL statements needded to alter the field in the table * PostgreSQL has some severe limits: -- 2.39.5