Create the migration
aml make:migration create_books_tableAML adds a timestamp prefix to the file under runtime/database/migrations. This ordering prevents changes from being applied randomly.
Describe the table
use AML\Data\Connection;
use AML\Data\Migrations\Migration;
use AML\Data\Schema\{Schema, Table};
return new class extends Migration {
public function up(Connection $connection): void
{
(new Schema($connection))->create('books', function (Table $table): void {
$table->id();
$table->string('title', 180);
$table->string('author', 120);
$table->timestamps();
});
}
public function down(Connection $connection): void
{
(new Schema($connection))->dropIfExists('books');
}
};Apply, inspect, reverse
aml data:migrate
aml data:status
aml data:rollback --steps 1
aml data:migrateThe migrator remembers what already ran: rerunning data:migrate applies only pending files. A lock prevents two processes from changing the schema simultaneously.
Rollback can mean data loss
Dropping a table in down() also removes its rows. Use rollback in controlled development and always back up production.