migrate

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdMigrate = &cobra.Command{
	Use:   "migrate [service...]",
	Short: "Dump ent schema DDL or generate versioned migration files",
	Long: `Two modes:

DDL dump (default) — for every service with an ent schema, render the table
definitions of the generated ent/migrate package into a CREATE TABLE script
for the target dialect via ent's schema.DDL — no live database connection is
required. The SQL file is written to migrations/schema.<dialect>.sql inside
each service directory; --out redirects all files into a single directory.
Services without an ent schema are skipped with a warning; missing ent
codegen is filled in automatically (as gow ent does).

Versioned migrations (--versioned) — for every service with an ent schema,
diff the ent schema against a development database and write the changes as
versioned migration files into the service's migrations/ directory, in the
file format of the selected migration tool. The dev database URL is
required and is never written into the generated program (it is passed as a
command-line argument at runtime). This follows ent's documented versioned
migration flow (schema.WithDir + ModeReplay + WithFormatter).

Examples:
  gow migrate                          # DDL dump, every ent-based service
  gow migrate admin --dialect postgres # DDL dump, one service
  gow migrate --versioned --url mysql://root:pass@localhost:3306/test
  gow migrate --versioned --tool golang-migrate --url "postgres://user:pass@localhost:5432/test?sslmode=disable"
  gow migrate admin --versioned --url mysql://root:pass@localhost:3306/test`,
	RunE:         RunDump,
	SilenceUsage: true,
}

CmdMigrate migrate 命令:把服务的 ent schema 逆向为 SQL DDL。

Functions

func RunDump

func RunDump(cmd *cobra.Command, args []string) error

RunDump 为 cobra 的 RunE 回调:解析服务并按模式分派。

Types

This section is empty.

Jump to

Keyboard shortcuts

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