I has created plugin with one migration. My version.yaml is
1.0.1: First version of user
1.0.2:
- Added new fields to User model
- alter_table_users_add_contact_fields.php
My updates directory contains one migration file 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);
}
}
I has successfully ran this migration using console command php artisan october:up
.
But now I want to rollback this migration. As I see there is no informatino about this migration in table migrations
. So I cant rollback this migration usins command php artisan migrate:rollback
.
I found that information about plugin version contains in table system_plugin_versions
. I has manually deleted my table mnv_news_read
and manually deleted correspond records from system_plugin_versions
and system_plugin_history
tables.
drop table mnv_news_read;
delete from system_plugin_history where code = 'Mnv.Reminder';
delete from system_plugin_versions where code = 'Mnv.Reminder';
After that I tryed to run php artisan october:up
again. It completed successfully.
My question is how to rollback plugin's migration correctly?
One way of rolling back migrations is via the builder plugin in admin control panel (make sure to install this plugin first if you have not already).
Versions
Rollback version
button