# Migrations

Miru Migrations is based on FluentMigrator

Migrations are a convenient way to alter your database schema over time in a consistent and easy way.

# Create

Can be created using Miru Makers:

miru make:migration CreateWithdraws

Migrations can be located at /src/App/Database/Migrations.

It's possible to pass with table is being manipulated:

miru make:migration CreateWithdraws --table Withdraws

# Migration

Migration is a class that sets a version of the schema change and the changes:

[Migration(202010202107)]
public class CreateWithdraws : AutoReversingMigration
{
    public override void Up()
    {
        Create.Table("TableName")
            .WithColumn("Id").AsId()
            .WithColumn("Name").AsString(64);
    }
}

More details can be seen at FluentMigrator's documentation

# Running

Miru comes with commands to be called from command-line. Some of them manage migrations.

# Migrate Up

Execute migrations that haven't been executed yet.

miru db:migrate

# Rollback

Rollback migrations to the last version.

miru db:rollback

# Reset

Reset database rolling back all and executing all migrations again.

miru db:reset

# Environment

By default, migration commands run in Development environment. To run in a different one, use -e or --environment arguments:

miru db:reset -e Test

miru db:migrate --environment Staging