migration

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatPlan

func FormatPlan(plan PlanResult) string

FormatPlan returns a human-friendly summary grouped by table and severity.

Types

type ApplyOptions

type ApplyOptions struct {
	AllowDropColumns     bool
	AllowDropIndexes     bool
	AllowDropConstraints bool
}

ApplyOptions controls execution of destructive statements

type ManualOptions

type ManualOptions struct {
	AllowTableDrop  bool // allow DROP TABLE in down migrations
	AllowColumnDrop bool // allow ALTER TABLE ... DROP COLUMN in down migrations
}

ManualOptions controls safety gates for manual file-based migrations

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator handles migrations and schema management

func NewMigrator

func NewMigrator(pool *pgxpool.Pool) *Migrator

func (*Migrator) AutoMigrate

func (m *Migrator) AutoMigrate(ctx context.Context, models ...any) error

AutoMigrate is a placeholder implementation

func (*Migrator) AutoMigrateWithOptions

func (m *Migrator) AutoMigrateWithOptions(ctx context.Context, opts ApplyOptions, models ...any) error

AutoMigrateWithOptions applies plan with additional options (e.g., allow drops)

func (*Migrator) MigrateDownDir

func (m *Migrator) MigrateDownDir(ctx context.Context, dir string, steps int) error

MigrateDownDir rolls back the last N applied migrations using .down.sql files

func (*Migrator) MigrateUpDir

func (m *Migrator) MigrateUpDir(ctx context.Context, dir string) error

MigrateUpDir applies pending .up.sql migrations from dir in ascending version order

func (*Migrator) Plan

func (m *Migrator) Plan(ctx context.Context, models ...any) (PlanResult, error)

Plan computes a safe migration plan for given models (public schema)

func (*Migrator) SetManualOptions

func (m *Migrator) SetManualOptions(opts ManualOptions)

SetManualOptions sets safety options for manual migrations

type PlanResult

type PlanResult struct {
	Statements            []string
	UnsafeStatements      []string
	Warnings              []string
	DestructiveStatements []string
	IndexDrops            []string
	ConstraintDrops       []string
}

PlanResult is a preview of migration operations

Jump to

Keyboard shortcuts

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