migrations

command
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 2 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL