Migration Example
Run these commands from the repository root. Install Atlas Community Edition
first (curl -sSf https://atlasgo.sh | sh -s -- --community).
Generate
gombit db makemigrations create_products \
--driver sqlite \
--model github.com/gombit-dev/gombit/examples/migrations/internal/product.Product
This demonstrates the feature-package model path used by the temporary Atlas
Program Mode loader. The generated migration files are written to
database/migrations unless --dir is provided.
Apply, status, and rollback
After generating an up migration, add a companion down file with the same
version/name prefix, for example:
database/migrations/20260101000000_create_products.sql
database/migrations/downs/20260101000000_create_products.down.sql
Configure the database (defaults are SQLite) and run:
export GOMBIT_DATABASE_DRIVER=sqlite
export GOMBIT_DATABASE_DSN='file:gombit.db?cache=shared&_fk=1'
gombit db status
gombit db migrate
gombit db status
gombit db rollback
migrate wraps atlas migrate apply and records the applied versions in
framework_migrations as one batch. rollback executes the latest batch's
downs/*.down.sql files and clears both Gombit and Atlas revision rows for those
versions.
Seed and reset
Add SQL seed files under database/seeds/ (lexical order). This example includes
database/seeds/01_demo.sql:
# from the repository root, after configuring GOMBIT_DATABASE_* as above.
# --dir points at the app migration directory (default/repo-root
# database/migrations from makemigrations); --seeds can point at this example.
gombit db seed --seeds examples/migrations/database/seeds
gombit db reset --dir database/migrations --seeds examples/migrations/database/seeds
Or create seeds next to your app migrations:
mkdir -p database/seeds
cat > database/seeds/01_demo.sql <<'SQL'
-- Example seed. Adjust to match your migrated schema.
-- INSERT INTO products (name) VALUES ('demo');
SELECT 1;
SQL
gombit db seed
gombit db reset
seed runs every *.sql file in --seeds (default database/seeds).
reset drops the schema, migrates, then seeds. In production, pass --force
to allow reset.