/** * @param AlterTable $table * @param mixed $data * * @return string */ protected function handleRenameColumn(AlterTable $table, $data) { return 'sp_rename ' . $this->wrap($table->getTableName()) . '.' . $this->wrap($data['from']) . ', ' . $this->wrap($data['column']->getName()) . ', COLUMN'; }
/** * @param AlterTable $column * @param mixed $data * * @return string */ protected function handleRenameColumn(AlterTable $table, $data) { $table_name = $table->getTableName(); $column_name = $data['from']; $new_name = $data['column']->getName(); $columns = $this->connection->schema()->getColumns($table_name, false, false); $column_type = isset($columns[$column_name]) ? $columns[$column_name]['type'] : 'integer'; return 'ALTER TABLE ' . $this->wrap($table_name) . ' CHANGE ' . $this->wrap($column_name) . ' ' . $this->wrap($new_name) . ' ' . $column_type; }
/** * @param AlterTable $schema * * @return array */ public function alter(AlterTable $schema) { $commands = array(); foreach ($schema->getCommands() as $command) { $type = 'handle' . ucfirst($command['type']); $sql = $this->{$type}($schema, $command['data']); if ($sql === null) { continue; } $commands[] = array('sql' => $sql, 'params' => $this->getParams()); } return $commands; }
/** * @param AlterTable $table * @param mixed $data * * @return string */ protected function handleDropIndex(AlterTable $table, $data) { return 'DROP INDEX ' . $this->wrap($table->getTableName() . '_' . $data); }
/** * @param AlterTable $table * @param mixed $data * * @return string */ protected function handleDropDefaultValue(AlterTable $table, $data) { return 'ALTER TABLE ' . $this->wrap($table->getTableName()) . ' MODIFY ' . $this->wrap($data) . ' DEFAULT NULL'; }