Migrations are especially useful when you want to add extra columns to your table. Lets say you have a migration for your user.
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable();
$table->string('email')->unique();
$table->string('password', 60);
$table->dateTime('password_updated_at')->nullable();
$table->rememberToken();
$table->timestamps();
});
}
public function down()
{
Schema::drop('users');
}
Now if you want to add an extra column you can simple create a new migration that will add that column
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->date('birthday')->nullable();
$table->boolean('active')->default(0);
});
}
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumns(['birthday', 'active']);
});
}
As you can see in the down method we remove the columns again. This is really useful when developing, so you can rebuild your database from a certain point.
I actually never had to revert a migration on producten, as long as you test it good enough on your local environment ;)
If you have more questions just let me know!