migrate

package
v0.0.0-...-1746241 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 21 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Migrate Service

Responsibility

Migration CLI command orchestration, migration file generation and collection automigration hooks. This is an infra/tooling service, not a business-domain feature module.

Structure

  • service.go — service descriptor, factory and command binding
  • config.go — migrate dir/language/automigrate config
  • command.go — CLI command implementation
  • templates.go — generated migration templates
  • runtime.go — migration runtime helpers
  • apis/ — reserved, no default HTTP API
  • forms/ — reserved validation DTO package
  • queries/ — reserved read-side helper package
  • migrations/ — intentionally empty for this tooling service

Dependencies

  • core.App
  • cobra
  • shared migrations/dbase registry

Public flows

  • Bind the migrate CLI command.
  • Generate JS/Go migration stubs.
  • Generate collection snapshots.
  • Wire automigration hooks when enabled.

Migration notes

The migrate service should not own product schema migrations. Domain migrations live in services/<service>/migrations and are registered by migrations/dbase/*_module.go.

Documentation

Overview

Package migrate provides migration command orchestration, migration file generation and collection automigration hooks.

Index

Constants

View Source
const TemplateLangGo = "go"

Variables

View Source
var Descriptor = servicebase.Descriptor{
	Name:    "migrate",
	Purpose: "Provides migration command binding, migration file generation and collection automigration hooks.",
	Dependencies: []string{
		"core.App",
		"cobra",
		"dbase migrations registry",
	},
	RuntimeState: []string{
		"cached collection snapshots in app store when automigrate is enabled",
	},
	Operations: []string{
		"Bind",
		"CreateCommand",
		"CreateMigration",
		"CreateCollectionsSnapshot",
	},
}

Functions

func MustRegister

func MustRegister(app core.App, rootCmd *cobra.Command, config Config)

MustRegister is a compatibility helper that binds the service to the root command and panics on error.

func Register

func Register(app core.App, rootCmd *cobra.Command, config Config) error

Register is a compatibility helper that binds the service to the root command.

Types

type Config

type Config struct {
	// Dir specifies the directory with the user defined migrations.
	//
	// If not set it defaults to a path relative to the app data directory.
	Dir string

	// Automigrate specifies whether to enable collection automigrations.
	Automigrate bool
}

Config defines the migrate service options.

type Service

type Service struct {
	servicebase.Service
	// contains filtered or unexported fields
}

Service provides migration command orchestration and automigrate hooks.

func New

func New(app core.App, config Config) *Service

New creates a migrate service bound to the provided app and config.

func (*Service) Bind

func (s *Service) Bind(rootCmd *cobra.Command) error

Bind attaches the migrate command to the provided root command and wires automigrate hooks when enabled.

func (*Service) CreateCollectionsSnapshot

func (s *Service) CreateCollectionsSnapshot(interactive bool, extraArgs ...string) (string, error)

CreateCollectionsSnapshot creates a snapshot migration for current collections.

func (*Service) CreateCommand

func (s *Service) CreateCommand() *cobra.Command

CreateCommand builds the cobra migrate command bound to the service.

func (*Service) CreateMigration

func (s *Service) CreateMigration(name string, interactive bool) (string, error)

CreateMigration creates a new migration file using the blank template.

Directories

Path Synopsis
Package apis is reserved for migrate service HTTP bindings.
Package apis is reserved for migrate service HTTP bindings.
Package forms contains migrate command/request forms when migrate flows need validation-oriented DTOs.
Package forms contains migrate command/request forms when migrate flows need validation-oriented DTOs.
Package migrations is intentionally empty for the migrate tooling service.
Package migrations is intentionally empty for the migrate tooling service.
Package queries contains migrate service read-side helpers.
Package queries contains migrate service read-side helpers.

Jump to

Keyboard shortcuts

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