From 1e0b3e25e3041c286eef6da7801a5dfeac7e53b9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 10 Apr 2011 23:45:30 +0200 Subject: - Patch #935258 by Stevel, Josh Waihi: defaults not changed in changeField on postgresql. --- includes/database/pgsql/schema.inc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'includes/database/pgsql') diff --git a/includes/database/pgsql/schema.inc b/includes/database/pgsql/schema.inc index 01e7c7c25..9ed8a2620 100644 --- a/includes/database/pgsql/schema.inc +++ b/includes/database/pgsql/schema.inc @@ -527,6 +527,9 @@ class DatabaseSchema_pgsql extends DatabaseSchema { $this->connection->query('ALTER TABLE {' . $table . '} DROP CONSTRAINT "' . $check . '"'); } + // Remove old default. + $this->fieldSetNoDefault($table, $field); + $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" TYPE ' . $typecast . ' USING "' . $field . '"::' . $typecast); if (isset($spec['not null'])) { @@ -561,6 +564,11 @@ class DatabaseSchema_pgsql extends DatabaseSchema { $this->connection->query('ALTER TABLE {' . $table . '} ADD CHECK ("' . $field_new . '" >= 0)'); } + // Add default if necessary. + if (isset($spec['default'])) { + $this->fieldSetDefault($table, $field_new, $spec['default']); + } + // Change description if necessary. if (!empty($spec['description'])) { $this->connection->query('COMMENT ON COLUMN {' . $table . '}."' . $field_new . '" IS ' . $this->prepareComment($spec['description'])); -- cgit v1.2.3