@@ -137,7 +137,7 @@ protected function _alter_table($alter_type, $table, $field)
137137
138138 $ sql = 'ALTER TABLE ' .$ this ->db ->escape_identifiers ($ table );
139139 $ sqls = array ();
140- for ($ i = 0 , $ c = count ($ field ), $ sql .= $ alter_type . ' ' ; $ i < $ c ; $ i ++)
140+ for ($ i = 0 , $ c = count ($ field ); $ i < $ c ; $ i ++)
141141 {
142142 if ($ field [$ i ]['_literal ' ] !== FALSE )
143143 {
@@ -146,13 +146,14 @@ protected function _alter_table($alter_type, $table, $field)
146146
147147 if (isset ($ field [$ i ]['type ' ]))
148148 {
149- $ sqls [] = $ sql .' TYPE ' .$ field [$ i ]['type ' ].$ field [$ i ]['length ' ];
149+ $ sqls [] = $ sql .' ALTER COLUMN ' .$ this ->db ->escape_identififers ($ field [$ i ]['name ' ])
150+ .' TYPE ' .$ field [$ i ]['type ' ].$ field [$ i ]['length ' ];
150151 }
151152
152153 if ( ! empty ($ field [$ i ]['default ' ]))
153154 {
154- $ sqls [] = $ sql .' ALTER ' .$ this ->db ->escape_identifiers ($ field [$ i ]['name ' ])
155- .' SET ' .$ field [$ i ]['default ' ];
155+ $ sqls [] = $ sql .' ALTER COLUMN ' .$ this ->db ->escape_identifiers ($ field [$ i ]['name ' ])
156+ .' SET DEFAULT ' .$ field [$ i ]['default ' ];
156157 }
157158
158159 if (isset ($ field [$ i ]['null ' ]))
@@ -165,7 +166,7 @@ protected function _alter_table($alter_type, $table, $field)
165166
166167 if ( ! empty ($ field [$ i ]['new_name ' ]))
167168 {
168- $ sqls [] = $ sql .' ALTER ' .$ this ->db ->escape_identifiers ($ field [$ i ]['name ' ])
169+ $ sqls [] = $ sql .' ALTER COLUMN ' .$ this ->db ->escape_identifiers ($ field [$ i ]['name ' ])
169170 .' TO ' .$ this ->db ->escape_identifiers ($ field [$ i ]['new_name ' ]);
170171 }
171172 }
0 commit comments