migrate

package
v0.1.0-rc.49 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Generate      GenerateCmd      `` /* 431-byte string literal not displayed */
	List          ListCmd          `cmd:"" help:"List migrations stored on the console for a project. Optional connection-name filter + pagination."`
	PushRaw       PushRawCmd       `` /* 144-byte string literal not displayed */
	Status        StatusCmd        `cmd:"" help:"Show each connection's pinned target migration + how many fetched artifacts are on disk. Offline, read-only."`
	Reset         ResetCmd         `` /* 258-byte string literal not displayed */
	VerifyHistory VerifyHistoryCmd `` /* 289-byte string literal not displayed */
	Squash        SquashCmd        `` /* 265-byte string literal not displayed */
}

Cmd is the single `w17ctl migrate` parent — every migration-related verb lives here:

migrate generate   — compile the proto schema + push it to the
                     console, which plans + stores the SQL
                     migrations and pins the lock target
migrate list       — browse stored migration history (console)
migrate push-raw   — push a hand-authored YAML body (escape hatch)
migrate reset      — DEV-ONLY destructive recreate: drop the DB,
                     discard the console's migration history, and
                     push a fresh baseline
migrate verify-history — ask whether the recorded history reproduces
                     the stored schema (the clean-gate; read-only)
migrate squash     — freeze a change request with its migrations:
                     collapse the history into one baseline the
                     collapsed rows point at (they are KEPT, which
                     is what separates this from reset)

FETCH, APPLY AND ROLLBACK ARE NOT HERE. They belong to the generated binary that owns the database — see the note at the top of apply.go. This client generates migrations; it does not write to a database.

The console is the single source of truth: it diffs the schema and emits the migrations. The old offline migrator tools (a local SQL `generate`, `verify`, `inspect`) are gone — there is no offline migration pipeline; `migrate generate` always goes through the console.

type GenerateCmd

type GenerateCmd struct {
	Protos     []string `` /* 171-byte string literal not displayed */
	Imports    []string `` /* 188-byte string literal not displayed */
	ProjectID  string   `` /* 127-byte string literal not displayed */
	Console    string   `` /* 217-byte string literal not displayed */
	LockPath   string   `` /* 202-byte string literal not displayed */
	NoLock     bool     `` /* 153-byte string literal not displayed */
	Initial    bool     `` /* 205-byte string literal not displayed */
	Decide     []string `` /* 273-byte string literal not displayed */
	Initiative string   `` /* 257-byte string literal not displayed */
}

GenerateCmd backs `w17ctl migrate generate` — the compiled-IR push to the console (formerly `w17ctl schema create/update`). It auto-detects create vs update by probing whether the project already has a stored schema, so the caller never picks the mode by hand; --initial forces the initial (create) push. The push machinery lives in internal/schema (RunSchemaPush).

func (*GenerateCmd) Run

func (c *GenerateCmd) Run() error

type ListCmd

type ListCmd struct {
	ProjectID  string `name:"project" short:"p" placeholder:"ID" required:"" help:"Project identifier."`
	Connection string `` /* 153-byte string literal not displayed */
	From       string `name:"from" placeholder:"MIGRATION_ID" help:"Optional pagination cursor. Returned list starts strictly after this ID."`
	UpTo       string `name:"up-to" placeholder:"MIGRATION_ID" help:"Optional upper bound. Stream stops after emitting this ID."`
	Console    string `` /* 217-byte string literal not displayed */
}

ListCmd backs `w17ctl migrate list` — it queries the console's stored migration history.

func (*ListCmd) Run

func (c *ListCmd) Run() error

type PushRawCmd

type PushRawCmd struct {
	ProjectID  string `` /* 160-byte string literal not displayed */
	Connection string `` /* 148-byte string literal not displayed */
	BodyPath   string `` /* 174-byte string literal not displayed */
	Console    string `` /* 217-byte string literal not displayed */
	Initiative string `` /* 284-byte string literal not displayed */
}

PushRawCmd backs `w17ctl migrate push-raw` — a single- migration escape hatch (D-iter3-26) for hand-authored YAML bodies the schema-driven planner can't auto-emit, typically TRANSFORM_FIELD ops carrying author-supplied Starlark scripts. Reads the YAML body from a file, ships it to console via the PushRawMigration RPC. Console validates + signs + stores; returns the assigned migration id.

Use case: TRANSFORM_FIELD with a Starlark script the auto-emit path can't produce from a schema diff. Operator authors the YAML by hand; this command pushes it as the next migration on (project, connection).

**Escape hatch caveat:** the supplied body's effect must be consistent with the project's stored schema. Console doesn't verify the YAML's ops align with column / table state — that's the author's responsibility.

func (*PushRawCmd) Run

func (c *PushRawCmd) Run() error

type ResetCmd

type ResetCmd struct {
	Force     bool     `` /* 221-byte string literal not displayed */
	Up        bool     `` /* 129-byte string literal not displayed */
	ProjectID string   `name:"project" placeholder:"ID" help:"Project whose migration history is discarded. Empty = read project_id from the lock."`
	Console   string   `` /* 215-byte string literal not displayed */
	Protos    []string `` /* 239-byte string literal not displayed */
	Imports   []string `` /* 188-byte string literal not displayed */
	LockPath  string   `` /* 149-byte string literal not displayed */
	NoLock    bool     `name:"no-lock" help:"Skip the lock-file write on the baseline push. Only read when --proto is given."`
	LocalOnly bool     `` /* 249-byte string literal not displayed */
}

ResetCmd implements `w17ctl migrate reset`.

func (*ResetCmd) Run

func (c *ResetCmd) Run() error

type SquashCmd

type SquashCmd struct {
	Force      bool     `` /* 126-byte string literal not displayed */
	Initiative string   `` /* 273-byte string literal not displayed */
	All        bool     `` /* 198-byte string literal not displayed */
	ProjectID  string   `name:"project" placeholder:"ID" help:"Project whose history is collapsed. Empty = read project_id from the lock."`
	Console    string   `` /* 215-byte string literal not displayed */
	Protos     []string `` /* 245-byte string literal not displayed */
	Imports    []string `` /* 188-byte string literal not displayed */
	LockPath   string   `` /* 149-byte string literal not displayed */
	NoLock     bool     `name:"no-lock" help:"Skip the lock-file write on the baseline push. Only read when --proto is given."`
}

SquashCmd implements `w17ctl migrate squash`.

func (*SquashCmd) Run

func (c *SquashCmd) Run() error

type StatusCmd

type StatusCmd struct {
	MigrationsDir string `` /* 153-byte string literal not displayed */
}

StatusCmd reports, per lock-listed connection, the pinned target migration and how many fetched artifacts sit on disk. Fully OFFLINE + read-only — the local counterpart absorbed from w17migrate's `status`.

func (*StatusCmd) Run

func (c *StatusCmd) Run() error

type VerifyHistoryCmd

type VerifyHistoryCmd struct {
	ProjectID string `name:"project" placeholder:"ID" help:"Project to check. Empty = read project_id from the lock."`
	Console   string `` /* 162-byte string literal not displayed */
	Strict    bool   `` /* 286-byte string literal not displayed */
}

VerifyHistoryCmd implements `w17ctl migrate verify-history` — the clean-gate, asked out loud.

The predicate has existed server-side since revisions landed and had NO client surface: it ran only as `UpdateSchema`'s own drift guard, so the only way an operator ever met the answer was a push refused with it quoted in the error. That is late and back-to-front — the question "does my recorded history actually reproduce my stored schema" is one you want answered BEFORE deciding to squash, reset or import, not as the reason a push you already meant to make was rejected.

Import (docs/decisions/project-import.md) is what forced it: only a history that provably reproduces its schema may be re-signed under a new scope, because after the re-signing nobody can tell the difference.

func (*VerifyHistoryCmd) Run

func (c *VerifyHistoryCmd) Run() error

Jump to

Keyboard shortcuts

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