summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/postgre
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-22 12:12:22 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-22 12:12:22 +0100
commit7ade8b7944d10f4fd1583789309cf003a3eac6f7 (patch)
treeb5b305d5d8ffb781682914a40f19ae8aa9dac477 /system/database/drivers/postgre
parent2eaeee5aa3971932e58ffac48554e554d799249f (diff)
Fix modify_column() issues (#2020)
Diffstat (limited to 'system/database/drivers/postgre')
-rw-r--r--system/database/drivers/postgre/postgre_forge.php13
1 files changed, 7 insertions, 6 deletions
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 425622fac..5e378385c 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -96,7 +96,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
$sqls = array();
- for ($i = 0, $c = count($field), $sql .= $alter_type.' '; $i < $c; $i++)
+ for ($i = 0, $c = count($field); $i < $c; $i++)
{
if ($field[$i]['_literal'] !== FALSE)
{
@@ -105,24 +105,25 @@ class CI_DB_postgre_forge extends CI_DB_forge {
if (version_compare($this->db->version(), '8', '>=') && isset($field[$i]['type']))
{
- $sqls[] = $sql.' TYPE '.$field[$i]['type'].$field[$i]['length'];
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
+ .' TYPE '.$field[$i]['type'].$field[$i]['length'];
}
if ( ! empty($field[$i]['default']))
{
- $sqls[] = $sql.' ALTER '.$this->db->escape_identifiers($field[$i]['name'])
- .' SET '.$field[$i]['default'];
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
+ .' SET DEFAULT '.$field[$i]['default'];
}
if (isset($field[$i]['null']))
{
- $sqls[] = $sql.' ALTER '.$this->db->escape_identifiers($field[$i]['name'])
+ $sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
.($field[$i]['null'] === TRUE ? ' DROP NOT NULL' : ' SET NOT NULL');
}
if ( ! empty($field[$i]['new_name']))
{
- $sqls[] = $sql.' RENAME '.$this->db->escape_identifiers($field[$i]['name'])
+ $sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
.' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
}
}