我已經將名稱爲im_useless
的列插入到我的表中,而我之前不需要該列。Laravel 5 - 使用migrate:回滾路徑
這是我的架構(文件名:2017_02_27_120313_units.php):
public function up()
{
Schema::create('units', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('description');
$table->string('im_useless');
$table->timestamps();
});
}
現在我嘗試刪除它,所以我用了down()
函數內部的代碼:
public function down()
{
Schema::dropColumn('im_useless');
}
新模式:
public function up()
{
Schema::create('units', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('description');
$table->timestamps();
});
}
現在我必須回滾然後再次遷移。我嘗試通過執行php artisan help migrate:rollback
僅回滾該特定的遷移文件,我發現有一個--path
選項。
於是,我就回滾像這樣的特定遷移:
php artisan migrate:rollback --path=2017_02_27_120313_units.php
,但我得到Nothing to rollback
我怎麼能丟棄,而不必回滾任何其他遷移特定的列?
UPDATE:
我想我必須改變path
這樣的:
php artisan migrate:rollback --path=database/migrations/2017_02_27_120313_units.php
...因爲我的php殼是在項目的根文件夾中打開?
但是我仍然得到Nothing to rollback
我也試過php artisan migrate --path=2017_02_27_120313_units.php
和php artisan migrate --path=database/migrate/2017_02_27_120313_units.php
...並獲得Nothing to migrate
更新2
我想我已經搞砸我的遷移表,因爲我刪除了down()
函數中的代碼,並且該表從未被刪除。 https://stackoverflow.com/a/26077506/4684797
使用遷移不僅僅是直接做業務數據庫如要複雜得多與phpmyadmin ...多數民衆贊成我今天所學 – Black