问题
How can I alter table or reset the auto-increment of a field in Yii 1.x, using CDbMigration?
I found alterColumn method, as good as createTable, dropTable, renameTable and truncateTable methods, but either I'm blind or there isn't anything for altering table or resetting the auto-increment of particular column or field.
回答1:
You can use execute() as Yii defines it:
Executes a SQL statement. This method executes the specified SQL statement using dbConnection.
So,
$this->execute("ALTER TABLE tbl_name AUTO_INCREMENT = 1");
来源:https://stackoverflow.com/questions/27402950/alter-table-or-reset-auto-increment-using-cdbmigration