diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-12-14 19:33:22 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-12-14 19:33:22 +0000 |
commit | 53c10fbf0f6dc03dead544c4f44bfcbfb18e0525 (patch) | |
tree | 0ef7d15f45ce32625c037532957b0b18049a0d52 /includes/database | |
parent | e091d1aca22b0b6f1e6df846fbba360be382ee70 (diff) | |
download | brdo-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')
-rw-r--r-- | includes/database/pgsql/schema.inc | 10 |
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 |