Commands
This guide is the reference for every Ace command Lucid ships with. Commands fall into four families: make:* for scaffolding files, migration:* for applying and rolling back schema changes, db:* for seeding and clearing data, and schema:* for working with the generated database/schema.ts file and schema dumps.
Every command accepts the flags documented below alongside AdonisJS's standard command flags (like --help).
make:migration
Creates a new migration file inside database/migrations with a timestamped filename.
node ace make:migration posts --create=posts
-
name (argument)
-
Name of the migration file. Lucid prefixes the file with a timestamp automatically.
-
--connection, -c <name>
-
Select the database connection the migration belongs to. The file is created inside that connection's first configured migration path.
-
--folder <path>
-
Select the migration directory when the connection has multiple migration paths configured.
-
--create <table>
-
Scaffold a migration that creates the given table. This is the default action.
-
--alter <table>
-
Scaffold a migration that alters the given table instead of creating one.
-
--contents-from <path>
-
Use the contents of the given file as the generated migration source, bypassing the default template.
-
--force, -f
-
Overwrite the file if it already exists.
make:model
Creates a new Lucid model file inside app/models. The generated class extends the schema class for the corresponding table by default.
node ace make:model Post
-
name (argument)
-
Name of the model class. Lucid converts it to snake_case for the filename.
-
--migration
-
Generate a matching migration file alongside the model.
-
--controller
-
Generate a matching resourceful controller for the model.
-
--transformer
-
Generate a matching transformer file for the model.
-
--factory
-
Generate a matching factory file for the model.
-
--contents-from <path>
-
Use the contents of the given file as the generated model source.
-
--force
-
Overwrite the file if it already exists.
make:factory
Creates a new model factory inside database/factories.
node ace make:factory Post
-
model (argument)
-
Name of the model the factory produces. Lucid imports the model into the factory file.
-
--contents-from <path>
-
Use the contents of the given file as the generated factory source.
-
--force, -f
-
Overwrite the file if it already exists.
make:seeder
Creates a new seeder file inside database/seeders.
node ace make:seeder User
-
name (argument)
-
Name of the seeder class. The filename is derived from this name.
-
--contents-from <path>
-
Use the contents of the given file as the generated seeder source.
-
--force, -f
-
Overwrite the file if it already exists.
migration:run
Applies every pending migration in order, records each one in the adonis_schema table, and regenerates database/schema.ts when finished.
node ace migration:run
❯ migrated database/migrations/1720000000000_create_posts_table
❯ migrated database/migrations/1720000000001_create_comments_table
Migrated in 42 ms
-
--connection, -c <name>
-
Run migrations for the given connection instead of the default.
-
--force
-
Explicitly allow the command to run in production. Migration commands refuse to run in production unless this flag is present.
-
--dry-run
-
Print the SQL that would run without executing it. Useful for reviewing generated SQL in code review.
-
--compact-output
-
Emit a single-line summary instead of per-file progress lines.
-
--disable-locks
-
Skip the advisory lock that serializes concurrent migration runs. Only disable when you are certain no other process is migrating the same database.
-
--schema-path <path>
-
Load a schema dump file before running pending migrations. Used to bootstrap a fresh database from a schema dump without replaying the entire migration history. See the schema dumps guide.
-
--no-schema-generate
-
Skip regenerating
database/schema.tsafter the migrations apply. Default is to regenerate.
migration:rollback
Reverts the most recent batch of migrations. Pass --step to roll back a specific number of files, or --batch to roll back to a specific batch number.
node ace migration:rollback
node ace migration:rollback --step=2
node ace migration:rollback --batch=0
-
--connection, -c <name>
-
Roll back migrations on the given connection.
-
--force
-
Explicitly allow the command to run in production.
-
--dry-run
-
Print the SQL that would run without executing it.
-
--batch <number>
-
Roll back to the given batch number. Pass
0to roll back every migration. -
--step <number>
-
Roll back the given number of migration files regardless of batch.
-
--compact-output
-
Emit a single-line summary instead of per-file progress lines.
-
--disable-locks
-
Skip the advisory lock that serializes concurrent migration runs.
-
--no-schema-generate
-
Skip regenerating
database/schema.tsafter the rollback. Default is to regenerate.
migration:refresh
Rolls back every migration, then re-runs all migrations from scratch. Optionally runs seeders after the refresh when --seed is provided.
node ace migration:refresh
node ace migration:refresh --seed
-
--connection, -c <name>
-
Refresh migrations on the given connection.
-
--force
-
Explicitly allow the command to run in production.
-
--dry-run
-
Print the SQL that would run without executing it.
-
--seed
-
Run database seeders after the refresh completes.
-
--compact-output
-
Emit a single-line summary instead of per-file progress lines.
-
--disable-locks
-
Skip the advisory lock that serializes concurrent migration runs.
-
--no-schema-generate
-
Skip regenerating
database/schema.tsafter the refresh. Default is to regenerate.
migration:reset
Rolls back every migration without re-running them. Leaves the database with an empty migration history.
node ace migration:reset
-
--connection, -c <name>
-
Reset migrations on the given connection.
-
--force
-
Explicitly allow the command to run in production.
-
--dry-run
-
Print the SQL that would run without executing it.
-
--compact-output
-
Emit a single-line summary instead of per-file progress lines.
-
--disable-locks
-
Skip the advisory lock that serializes concurrent migration runs.
-
--no-schema-generate
-
Skip regenerating
database/schema.tsafter reset. Default is to regenerate.
migration:fresh
Drops every table in the database (plus views, types, and domains when flagged) and re-runs all migrations from scratch. Functionally similar to migration:refresh, but skips the rollback path in favor of dropping everything directly.
node ace migration:fresh
node ace migration:fresh --seed
-
--connection, -c <name>
-
Run on the given connection.
-
--force
-
Explicitly allow the command to run in production.
-
--seed
-
Run database seeders after migrations complete.
-
--drop-views
-
Drop all views before running migrations.
-
--drop-types
-
Drop all custom PostgreSQL types before running migrations. PostgreSQL only.
-
--drop-domains
-
Drop all PostgreSQL domains before running migrations. PostgreSQL only.
-
--disable-locks
-
Skip the advisory lock that serializes concurrent migration runs.
-
--schema-path <path>
-
Load a schema dump file before dropping and recreating the database. See the schema dumps guide.
migration:status
Lists every migration file and its status (pending, completed, or errored), grouped by batch.
node ace migration:status
┌───────────────────────────────────────────────┬───────────┬───────┬─────────┐
│ Name │ Status │ Batch │ Message │
├───────────────────────────────────────────────┼───────────┼───────┼─────────┤
│ 1720000000000_create_posts_table │ completed │ 1 │ │
│ 1720000000001_create_comments_table │ completed │ 1 │ │
│ 1720000000002_add_published_at_to_posts_table │ pending │ │ │
└───────────────────────────────────────────────┴───────────┴───────┴─────────┘
-
--connection, -c <name>
-
List status for the given connection.
db:seed
Runs every seeder inside database/seeders. Pass --files to run a specific subset, or --interactive to pick seeders interactively.
node ace db:seed
node ace db:seed --interactive
node ace db:seed --files=./database/seeders/user_seeder.ts
-
--connection, -c <name>
-
Run seeders against the given connection.
-
--interactive, -i
-
Select seeders to run interactively instead of running every file.
-
--files <paths...>
-
Run only the listed seeder files. Pass the flag multiple times or use a comma-separated list.
-
--compact-output
-
Emit a single-line summary instead of per-seeder progress lines.
db:wipe
Drops every table in the database, along with optionally all views, custom types, and domains. Combine with migration:run or use migration:fresh when you want to rebuild.
node ace db:wipe
-
--connection, -c <name>
-
Target the given connection.
-
--drop-views
-
Drop all views.
-
--drop-types
-
Drop all custom PostgreSQL types. PostgreSQL only.
-
--drop-domains
-
Drop all PostgreSQL domains. PostgreSQL only.
-
--force
-
Explicitly allow the command to run in production.
Tables listed in wipe.ignoreTables inside your connection config are preserved. See the configuration guide.
db:truncate
Truncates every table in the database, preserving schema. Useful when you want to reset data between tests or dev runs without dropping tables.
node ace db:truncate
-
--connection, -c <name>
-
Target the given connection.
-
--force
-
Explicitly allow the command to run in production.
schema:dump
Writes the current database schema to a single SQL file, alongside a sidecar JSON manifest. The dump is used by migration:run --schema-path and migration:fresh --schema-path to bootstrap a database without replaying the full migration history, which is useful for applications with long migration histories. See the schema dumps guide for the end-to-end workflow.
node ace schema:dump
node ace schema:dump --path=./database/schema.sql
-
--connection, -c <name>
-
Dump the schema for the given connection.
-
--path <path>
-
Write the dump to a custom location. Defaults to
database/schema/{connection}-schema.sql. -
--prune
-
Delete every migration file from the configured migration paths after dumping. Use this when collapsing a long migration history into a single schema dump. See squashing a long migration history.
schema:generate
Regenerates database/schema.ts by introspecting the database. Migration commands run this automatically when they finish, so this command is mainly useful when adopting a legacy database for the first time or after manual schema changes.
node ace schema:generate
❯ Generated database/schema.ts
-
--connection, -c <name>
-
Generate schema classes from the given connection.
-
--compact-output
-
Emit a single-line summary instead of detailed progress.