LazyRecord\Migration\Migration::renameColumn PHP Method

renameColumn() public method

Rename column requires $schema object.
public renameColumn ( $table, $oldColumn, $newColumn )
    public function renameColumn($table, $oldColumn, $newColumn)
    {
        if ($this->driver instanceof MySQLDriver && is_string($newColumn)) {
            throw new InvalidArgumentException('MySQLDriver requires the new column to be a column definition object.');
        }
        $query = new AlterTableQuery($table);
        $query->renameColumn($oldColumn, $newColumn);
        $sql = $query->toSql($this->driver, new ArgumentArray());
        $this->query($sql);
    }

Usage Example

 public function testMigrationRename()
 {
     if ($this->queryDriver instanceof SQLiteDriver) {
         return $this->markTestSkipped('skip this test when sqlite driver is used.');
     }
     $migration = new Migration($this->conn, $this->queryDriver, $this->logger);
     $author = new Author();
     $schema = $author->getDeclareSchema();
     $column = $schema->getColumn('name');
     $newColumn = clone $column;
     $newColumn->name('name2');
     $migration->renameColumn('authors', $column, $newColumn);
     $migration->renameColumn('authors', $newColumn, $column);
 }