This package makes it easy to create automatically reversible database migrations for common operations.
This way, you don't have to deal with the time-consuming and error-prone (not to mention stupid and boring) task of manually writing the down logic for your migrations.
Run composer require franzl/laravel-easy-migrations and you're good to go.
Please note that - just like with Laravel - you will need to install the doctrine/dbal package if you want to rename columns and/or drop SQLite columns.
To create a reversible migration, extend your migration class from the Franzl\EasyMigrations\EasyMigration base class.
Your task: Overwrite the change method, which needs to return another migration instance.
Luckily, this package already provides implementations for the most common migration operations.
The second parameter is an array of column definitions, with the key being the column name.
The value of each item is an array with the column definitions, as understood by Laravel's Illuminate\Database\Schema\Blueprint::addColumn() method.
The first option is the column type, any other keyed option is passed through to addColumn.
The following options are supported for all column types:
nullable: Whether the column allows NULL values, boolean, defaults to false
default: Column default value, mixed
unique: Creates a UNIQUE index for the column, boolean, defaults to false
first: Insert the column as the first in the table, boolean, defaults to false, MySQL only
after: Insert the column directly after the specified existing column, string, MySQL only
In the following, all supported types, along with custom options, are listed: