Migrations in this beta are Rust files, not a second language inside the binary. They compile into the app, so a deployed server can run migrate without your source tree. There is no down method and no rollback command. Rolling back by dropping columns is how production data disappears, so a change is a new forward migration.
From the Field Notes directory:
laravel make:migration create_notes_table
make:migration infers a new table from a name like create_notes_table and writes a file in database/migrations/ whose name starts with the current UTC time. That directory is the one the starter registers:
.with_migrations(laravel::db::migrations!("database/migrations"))
The macro embeds every .rs file directly inside that directory. Subdirectories are not scanned. Keep the new file next to the starter’s migrations, not in database/migrations/notes/.
build.rs already tells Cargo to watch the directory. Editing an existing migration rebuilds on its own. Adding a file depends on that build.rs line. Do not move the folder unless you also change src/app.rs and build.rs.
The notes table
Open the generated file and make migrate create the table. The types below are the schema builder’s, so PostgreSQL, MySQL, MariaDB, and SQLite each get the SQL that engine needs:
use laravel::db::AnyTransaction;
pub async fn migrate(tx: &mut AnyTransaction<'_>) -> laravel::Result<()> {
tx.schema()
.create("notes", |table| {
table.id();
table.foreign_id("user_id").constrained().cascade_on_delete();
table.string("title").length(120);
table.text("body");
table.timestamps();
})
.await
}
table.id() is the integer primary key the models guide expects for an i64 id. foreign_id("user_id").constrained() points at users. cascade_on_delete() removes a user’s notes when that user row goes away. string plus length(120) matches the title you will validate later. text holds the body. timestamps() adds created_at and updated_at.
&mut AnyTransaction wraps the migration and its row in the migrations table in one transaction on PostgreSQL and SQLite. A failure rolls back. MySQL and MariaDB implicitly commit on DDL such as CREATE TABLE, so a failed migration there can leave earlier statements applied. Keep one table change per file on those engines.
Run it:
laravel migrate
If the database does not exist yet, migrate offers to create it. The command records the filename without .rs. After this file has run on a shared database, do not edit or rename it. An edit will not run again. A rename runs a second time. During local development, before anyone else has the migration, you may change the file and rebuild with migrate:fresh. That command destroys the local database. Do not point it at a database you need to keep.
A later column is a new file, for example add_pinned_to_notes_table, using tx.schema().alter("notes", ...). Dropping a column you regret is also a new file. Framework tables you did not design, such as queue or workflow storage, can be created with a one-line macro (laravel::queue::tables!(), laravel::workflow::tables!()). The notes table is yours, so it stays as schema builder calls rather than a framework macro.
Check your work
After migrate, describe where the file lives and why editing it later will not change a database that already ran it.