2017-06-26 9 views
0

私は1回の移行でプラグインを作成しました。私version.yamlマイアップデートディレクトリは1つの移行ファイルalter_table_users_add_contact_fields.phpが含まれているOctoberCMSでプラグインの移行をロールバックする方法はありますか?

1.0.1: First version of user 
1.0.2: 
    - Added new fields to User model 
    - alter_table_users_add_contact_fields.php 

です。

<?php 

namespace Mnv\Reminder\Updates; 

use Schema; 
use October\Rain\Database\Updates\Migration; 

class CreateTableNewsRead extends Migration 
{ 
    protected $table = 'mnv_news_read'; 

    public function up() 
    { 
     Schema::create($this->table, function($table) 
     { 
      $table->engine = 'InnoDB'; 
      $table->increments('id'); 

      $table->integer('news_id'); 
      $table->foreign('news_id')->references('id')->on('rainlab_blog_posts')->onUpdate('cascade')->onDelete('cascade'); 

      $table->integer('user_id'); 
      $table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade'); 

      $table->timestamp('read_at'); 

      $table->index([ 
       'news_id', 
       'user_id', 
      ]); 

      $table->index([ 
       'user_id', 
       'news_id', 
      ]); 
     }); 
    } 

    public function down() 
    { 
     Schema::dropIfExists($this->table); 
    } 
} 

コンソールコマンドphp artisan october:upを使用してこの移行を正常に実行しました。

しかし、この移行をロールバックします。私が見ているように、テーブルmigrationsにはこの移行についての情報はありません。だから私はこの移行をコマンドロールバックすることはできませんphp artisan migrate:rollback

プラグインのバージョンに関する情報には、テーブルsystem_plugin_versionsが含まれています。手動でテーブルmnv_news_readを削除し、対応するレコードをsystem_plugin_versionssystem_plugin_historyテーブルから手動で削除しました。

drop table mnv_news_read; 
delete from system_plugin_history where code = 'Mnv.Reminder'; 
delete from system_plugin_versions where code = 'Mnv.Reminder'; 

その後、再度php artisan october:upを実行しようとしました。それは正常に完了しました。

私の質問は、プラグインの移行を正しくロールバックする方法です。

答えて

2

移行をロールバックする方法の1つは、管理者用コントロールパネルのbuilder pluginです(まだインストールしていない場合は、必ずこのプラグインをインストールしてください)。

  1. Versions
  2. 選択して選択し、左側のメニューから
  3. (ボタン「>」の矢印をクリックして)プラグインを選択します(ページの最上部から)Builderプラグインメニュー
  4. を選択ロールバックするバージョン
  5. Rollback versionボタンをクリックしてください。
関連する問題