]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/pgsqlschema.php
Update URLDetectionTest.php for rel="nofollow external". There are still some broken...
[quix0rs-gnu-social.git] / lib / pgsqlschema.php
index 7594edc8e3aace53ee060a1ac49312c3f958f505..272f7eff683f354e5ca72a42401e7e0ddd0c5c4c 100644 (file)
@@ -143,6 +143,7 @@ class PgsqlSchema extends Schema
         $uniques = array();
         $primary = array();
         $indices = array();
+       $onupdate = array();
 
         $sql = "CREATE TABLE $name (\n";
 
@@ -169,13 +170,7 @@ class PgsqlSchema extends Schema
         }
 
         if (count($primary) > 0) { // it really should be...
-            $sql .= ",\n primary key (" . implode(',', $primary) . ")";
-        }
-
-
-
-        foreach ($indices as $i) {
-            $sql .= ",\nindex {$name}_{$i}_idx ($i)";
+            $sql .= ",\n PRIMARY KEY (" . implode(',', $primary) . ")";
         }
 
         $sql .= "); ";
@@ -184,6 +179,10 @@ class PgsqlSchema extends Schema
         foreach ($uniques as $u) {
             $sql .= "\n CREATE index {$name}_{$u}_idx ON {$name} ($u); ";
         }
+
+        foreach ($indices as $i) {
+            $sql .= "CREATE index {$name}_{$i}_idx ON {$name} ($i)";
+        }
         $res = $this->conn->query($sql);
 
         if (PEAR::isError($res)) {
@@ -323,7 +322,7 @@ class PgsqlSchema extends Schema
 
     public function modifyColumn($table, $columndef)
     {
-        $sql = "ALTER TABLE $table MODIFY COLUMN " .
+        $sql = "ALTER TABLE $table ALTER COLUMN TYPE " .
           $this->_columnSql($columndef);
 
         $res = $this->conn->query($sql);
@@ -430,11 +429,12 @@ class PgsqlSchema extends Schema
         foreach ($tomod as $columnName) {
             $cd = $this->_byName($columns, $columnName);
 
-            $phrase[] = 'MODIFY COLUMN ' . $this->_columnSql($cd);
+       /* brute force */
+            $phrase[] = 'DROP COLUMN ' . $columnName;
+            $phrase[] = 'ADD COLUMN ' . $this->_columnSql($cd);
         }
 
         $sql = 'ALTER TABLE ' . $tableName . ' ' . implode(', ', $phrase);
-        echo "<p>$sql</p>";
         $res = $this->conn->query($sql);
 
         if (PEAR::isError($res)) {
@@ -508,7 +508,7 @@ class PgsqlSchema extends Schema
           return $sql;
         }
         if (!empty($cd->auto_increment)) {
-          $type = 'serial';
+           $type = "bigserial"; // FIXME: creates the wrong name for the sequence for some internal sequence-lookup function, so better fix this to do the real 'create sequence' dance.
         }
 
         if (!empty($cd->size)) {
@@ -523,9 +523,9 @@ class PgsqlSchema extends Schema
             $sql .= ($cd->nullable) ? "null " : "not null ";
         }
 
-        if (!empty($cd->extra)) {
-            $sql .= "{$cd->extra} ";
-        }
+//         if (!empty($cd->extra)) {
+//             $sql .= "{$cd->extra} ";
+//         }
 
         return $sql;
     }