rain

command
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 4 Imported by: 0

README

rain CLI

The rain CLI provides Rain's code-first migration workflow. It supports:

  • generate to diff the current schema registry against the latest persisted snapshot
  • migrate to apply generated SQL migrations
  • check to verify that the current schema still matches the latest migration snapshot

This design is intentionally similar to Drizzle Kit's code-first generate flow, but adapted to Go and Rain's schema model.

Design

generate works as a migration-chain operation:

  1. Load the configured schema registry and build a JSON snapshot from Rain table metadata.
  2. Read prior migration folders from the configured out directory in timestamp order.
  3. Compare the current snapshot to the newest snapshot in that chain.
  4. Write a new timestamped migration folder containing:
    • migration.sql
    • snapshot.json

Example layout:

rain/migrations/
  20260330121500_init/
    migration.sql
    snapshot.json
  20260330123010_add_posts/
    migration.sql
    snapshot.json

The migration folders are the source of truth. There is no mutable latest.snapshot.json. If any migration folder is missing migration.sql or snapshot.json, both generate and check fail until the chain is repaired. Rain v1 is forward-only. It does not generate or apply down migrations.

Registry

Rain uses an explicit schema registry package instead of file globs. The registry must export a function that returns the managed tables:

package registry

import "github.com/hyperlocalise/rain-orm/pkg/schema"

func ManagedTables() []schema.TableReference {
	return []schema.TableReference{Users, Posts, Memberships}
}

Config

Development config:

dialect: sqlite
schema_package: ./examples/schema/registry
schema_function: ManagedTables
out: rain/migrations
migration_table: rain_schema_migrations
dsn: app.sqlite

Deploy-only config for migrate:

dialect: sqlite
out: rain/migrations
migration_table: rain_schema_migrations
dsn: app.sqlite

migrate does not require schema source settings because it runs from generated artifacts only.

Commands

Generate a migration:

go run ./cmd/rain generate --name init

Apply pending migrations:

go run ./cmd/rain migrate

Check that the live schema registry matches the newest migration snapshot:

go run ./cmd/rain check

Current Scope

This v1 CLI is additive-first. It supports create-table, add-column, add-index, and safe additive constraint flows where the dialect supports them. It does not include:

  • Studio
  • direct schema push
  • database introspection / pull
  • rename prompts
  • automatic destructive diffs

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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