Skip to content

File-Based Migrations

Microbase tracks applied migrations in the _migrations table and reads .sql / .json files from ./mb_migrations.

Terminal window
# Create a new timestamped SQL migration
./microbase migrate create add_posts_index
# Apply pending migrations
./microbase migrate up
# Inspect status
./microbase migrate status
# Roll back the last migration
./microbase migrate down
# Export current schema as a JSON snapshot migration
./microbase migrate snapshot
-- +migrate Up
CREATE INDEX IF NOT EXISTS idx_posts_published ON posts (published);
-- +migrate Down
DROP INDEX IF EXISTS idx_posts_published;