summaryrefslogtreecommitdiff
path: root/includes/database/pgsql
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-12-14 19:33:22 +0000
committerDries Buytaert <dries@buytaert.net>2010-12-14 19:33:22 +0000
commit53c10fbf0f6dc03dead544c4f44bfcbfb18e0525 (patch)
tree0ef7d15f45ce32625c037532957b0b18049a0d52 /includes/database/pgsql
parente091d1aca22b0b6f1e6df846fbba360be382ee70 (diff)
downloadbrdo-53c10fbf0f6dc03dead544c4f44bfcbfb18e0525.tar.gz
brdo-53c10fbf0f6dc03dead544c4f44bfcbfb18e0525.tar.bz2
- Patch #974250 by Stevel: upgrade path broken on PostgreSQL: can't change NOT NULL.
Diffstat (limited to 'includes/database/pgsql')
-rw-r--r--includes/database/pgsql/schema.inc10
1 files changed, 10 insertions, 0 deletions
diff --git a/includes/database/pgsql/schema.inc b/includes/database/pgsql/schema.inc
index 1443bc5c0..f05cc0868 100644
--- a/includes/database/pgsql/schema.inc
+++ b/includes/database/pgsql/schema.inc
@@ -489,6 +489,16 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
$this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" TYPE ' . $typecast . ' USING "' . $field . '"::' . $typecast);
+ if (isset($spec['not null'])) {
+ if ($spec['not null']) {
+ $nullaction = 'SET NOT NULL';
+ }
+ else {
+ $nullaction = 'DROP NOT NULL';
+ }
+ $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" ' . $nullaction);
+ }
+
if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) {
// Type "serial" is known to PostgreSQL, but *only* during table creation,
// not when altering. Because of that, the sequence needs to be created