basic

command
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 7 Imported by: 0

README

basic

The smallest complete bun-migrator program. Two models (User, Post), a four-target registry (an enum, the shared updated_at function, and two tables), and migratecmd.Models as the entire CLI -- no other subcommands, no flags of its own.

Post is where every Table option lives at once: WithAutoUpdatedAt, DependsOn, ForeignKey, Index and LiveUniqueIndex. User is left plain so you can see what a table looks like with none of them.

Run it

Print the migrations without touching a database:

go run ./examples/basic --dry-run

Write them to disk instead of printing them:

go run ./examples/basic --out ./out

Plan just Post and see it pull in its dependencies (PostStatus, User):

go run ./examples/basic --dry-run Post

Print the down migrations a rollback would run, without running them:

go run ./examples/basic --dry-run --rollback

None of the above need DATABASE_URL or the PG_* variables -- those are only read when a real apply or rollback runs, which needs a live Postgres 14+ database.

What you should see

--dry-run prints four migration files (0001_create_type_post_status, 0002_create_function_auto_update_updated_at, 0010_create_table_users, 0011_create_table_posts), each as its up and down SQL, followed by a count. --dry-run Post prints three of those four -- User and PostStatus are pulled in as Post's dependencies, but User's own table has no dependency on Post so nothing else is added.

Documentation

Overview

Command basic is the smallest complete bun-migrator program: two models, a registry, and migratecmd.Models as the whole CLI.

Jump to

Keyboard shortcuts

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