yii\db\Migration::renameColumn PHP Method

renameColumn() public method

Builds and executes a SQL statement for renaming a column.
public renameColumn ( string $table, string $name, string $newName )
$table string the table whose column is to be renamed. The name will be properly quoted by the method.
$name string the old name of the column. The name will be properly quoted by the method.
$newName string the new name of the column. The name will be properly quoted by the method.
    public function renameColumn($table, $name, $newName)
    {
        echo "    > rename column {$name} in table {$table} to {$newName} ...";
        $time = microtime(true);
        $this->db->createCommand()->renameColumn($table, $name, $newName)->execute();
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  * Note: table will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function renameColumn($table, $name, $newName)
 {
     $table = $this->autoWrappedTableName($table);
     return parent::renameColumn($table, $name, $newName);
 }
All Usage Examples Of yii\db\Migration::renameColumn