【发布时间】:2017-09-03 17:57:11
【问题描述】:
我已经能够在 Codeigniter 中创建和运行迁移,但我无法回滚我的迁移。谁能帮助我如何在 codeigniter 中回滚迁移?
使用 Illuminate\Database\Capsule\Manager 作为 Capsule;
类 Migration_Create_language 扩展 CI_Migration {
public function up() {
Capsule::schema()->create('languages', function($table){
$table->increments('id');
$table->string('name', 120);
$table->string('country', 120);
$table->string('country_code', 20);
$table->enum('status', array('0','1'))->default('0');
$table->timestamps();
});
}
/*
* Sample function for rolling back the above action
*/
public function down()
{
Capsule::schema()->drop('languages');
}
}
【问题讨论】:
-
github.com/AimalAzmi/codeigniter-migrations 试试这个,我为此编写了一个库,可以通过 CLI 轻松使用。它可用于创建迁移文件并向后或向前运行迁移。
标签: php codeigniter migration rollback