loco-rs/loco · error
implement `up()` for the
Error message
implement `up()` for the `{{name}}` migration What it means
A panic raised by a `todo!()` in a freshly generated Loco migration. When the generator cannot infer a schema change from the migration name (e.g. `cargo loco generate migration AddPostsTable` is too ambiguous), it emits an empty migration whose `up()` panics with this message so that a no-op migration is never silently recorded in `_loco_migrations`.
Solutions
- Open migration/src/m<timestamp>_<name>.rs and implement `up()` using `loco_rs::schema` helpers (create_table, add_column, remove_column, rename_column, add_reference)
- Give `down()` the inverse operation so rollback works
- Alternatively delete the unused generated migration file and regenerate with a conventional name (e.g. CreatePosts) that the generator can infer
- Re-run `cargo loco db migrate`
Example fix
// before
async fn up(&self, _m: &SchemaManager) -> Result<(), DbErr> {
todo!("implement `up()` for the `AddPosts` migration")
}
// after
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.create_table(
Table::create()
.table(Posts::Table)
.col(ColumnDef::new(Posts::Id).integer().primary_key())
.col(ColumnDef::new(Posts::Title).string().not_null())
.to_owned(),
).await
} Defensive patterns
Strategy: validation
Validate before calling
grep -rL "todo!" migration/src/ || echo "some migrations are still stubs"
Prevention
- Always implement up()/down() immediately after `cargo loco generate migration`
- Use conventional migration names (CreateX, AddXToY, RemoveXFromY) so the generator infers the schema change
- Grep for `todo!` in migration/ as part of CI before running migrate
When it happens
Trigger: Running `cargo loco db migrate` (or anything that boots migrations) after generating a migration whose name the generator could not map to a schema change, without editing the `up()` body.
Common situations: Developers run `cargo loco generate migration` with a name that doesn't match Loco's naming conventions (e.g. `posts` instead of `CreatePosts`), then immediately run `db migrate`; CI pipelines fail on a migration stubbed earlier and forgotten.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- db cleanup thread panicked
- Type mismatch in RefGuard
- only enum supported
- failed to install Ctrl+C handler
- failed to install signal handler
AI-assisted analysis of loco-rs/loco@23639d1e36 (2026-09-12).
Data as JSON: /api/errors/76ccdfb44bed57d0.
Report an issue: GitHub.
Appendix: source
Thrown at loco-gen/src/templates/migration/empty.t:29
- into: "migration/src/lib.rs"
before: "pub struct Migrator"
content: "mod {{module_name}};"
---
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
// Loco could not infer a schema change from the name `{{name}}`, so this
// migration does nothing yet. Write the change here — the helpers in
// `loco_rs::schema` (`add_column`, `remove_column`, `rename_column`,
// `add_reference`, `create_table`, ...) cover the common cases — and
// give `down()` the inverse. Until then `db migrate` panics here rather
// than recording a migration that changed nothing.
todo!("implement `up()` for the `{{name}}` migration")
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
Ok(())
}
}
View on GitHub (pinned to 23639d1e36)