Search documentation

Find a page in the Andurel docs.

Migrations & Seeding

SQL migrations under root migrations/ are the schema source of truth. Named seed compositions live in root seeds/. Generated projects embed migration SQL so CLI commands, tests, and production binaries share one history.

Create and apply migrations

1andurel generate migration create_products_table
2andurel db migrate up
3andurel db migrate status

Generated file shape (migrations/00015_create_products_table.sql):

 1-- +goose Up
 2-- +goose StatementBegin
 3CREATE TABLE IF NOT EXISTS products (
 4    id uuid NOT NULL PRIMARY KEY,
 5    created_at TIMESTAMP WITH TIME ZONE NOT NULL,
 6    updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
 7    name VARCHAR(255) NOT NULL,
 8    price_cents INTEGER NOT NULL
 9);
10-- +goose StatementEnd
11
12-- +goose Down
13-- +goose StatementBegin
14DROP TABLE IF EXISTS products;
15-- +goose StatementEnd
Command Behavior
andurel db migrate up Apply pending migrations
andurel db migrate down Roll back the most recent migration
andurel db migrate up-to [version] Apply through a version
andurel db migrate down-to [version] Roll back down to a version
andurel db migrate reset Roll back all, then re-apply
andurel db migrate fix Re-number migrations to fix gaps
andurel db migrate status Show applied / pending state

migrate up and status print Goose text:

1OK   00015_create_products_table.sql (8.1ms)
1    Applied At                  Migration
2    =======================================
3    2026-09-23 14:02:11         00001_create_river_migration_table.sql
4    2026-09-23 14:05:02         00015_create_products_table.sql

narsilc output does not replace migrations. Write schema changes as SQL first, apply them, then andurel generate model / scaffold from the migrated table. See db.

Seeds

1andurel db seed
2andurel db seed development
3andurel db seed --list
4andurel db rebuild --seed test
1andurel db seed --list --json
1{
2  "ok": true,
3  "data": { "names": ["default", "development", "test"] },
4  "summary": "Found 3 seed sets"
5}

Seeds should call exported model and factory APIs. Keep development, test, and production-safe seed intent separate. andurel db rebuild drops and recreates the database, migrates, and seeds (pass --skip-seed to stop after migrate).

See Factories.