yii\db\Migration::renameTable PHP Method

renameTable() public method

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

Usage Example

Example #1
0
 /**
  * @inheritdoc
  * Note: table names will be auto pefixied if [[$autoWrapTableNames]] is true.
  */
 public function renameTable($table, $newName)
 {
     $table = $this->autoWrappedTableName($table);
     $newName = $this->autoWrappedTableName($newName);
     return parent::renameTable($table, $newName);
 }