postgresql

package
v0.0.0-...-4bc1af1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tracker

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

Tracker implements StateTracker for PostgreSQL

func NewTracker

func NewTracker(connStr string, schema string) (*Tracker, error)

NewTracker creates a new PostgreSQL state tracker

func (*Tracker) Close

func (t *Tracker) Close() error

Close closes the database connection

func (*Tracker) DeleteMigration

func (t *Tracker) DeleteMigration(ctx interface{}, migrationID string) error

DeleteMigration deletes a migration from migrations_list (cascades to history via foreign key)

func (*Tracker) GetLastMigrationVersion

func (t *Tracker) GetLastMigrationVersion(ctx interface{}, schema, table string) (string, error)

GetLastMigrationVersion gets the last applied version for a schema/table

func (*Tracker) GetMigrationDetail

func (t *Tracker) GetMigrationDetail(ctx interface{}, migrationID string) (*state.MigrationDetail, error)

GetMigrationDetail retrieves detailed information about a single migration from migrations_list

func (*Tracker) GetMigrationExecutions

func (t *Tracker) GetMigrationExecutions(ctx interface{}, migrationID string) ([]*state.MigrationExecution, error)

GetMigrationExecutions retrieves all execution records for a migration, ordered by created_at DESC

func (*Tracker) GetMigrationHistory

func (t *Tracker) GetMigrationHistory(ctx interface{}, filters *state.MigrationFilters) ([]*state.MigrationRecord, error)

GetMigrationHistory retrieves migration history with optional filters

func (*Tracker) GetMigrationList

func (t *Tracker) GetMigrationList(ctx interface{}, filters *state.MigrationFilters) ([]*state.MigrationListItem, error)

GetMigrationList retrieves the list of migrations with their last status

func (*Tracker) GetRecentExecutions

func (t *Tracker) GetRecentExecutions(ctx interface{}, limit int) ([]*state.MigrationExecution, error)

GetRecentExecutions retrieves recent execution records across all migrations, ordered by created_at DESC

func (*Tracker) GetSkippedMigrations

func (t *Tracker) GetSkippedMigrations(ctx interface{}, migrationID string, limit int) ([]*state.SkippedMigration, error)

GetSkippedMigrations retrieves skipped migrations, optionally filtered by migration_id or recent limit

func (*Tracker) Initialize

func (t *Tracker) Initialize(ctx interface{}) error

Initialize creates the migration state tables

func (*Tracker) IsMigrationApplied

func (t *Tracker) IsMigrationApplied(ctx interface{}, migrationID string) (bool, error)

IsMigrationApplied checks if a migration has been successfully applied. This only returns true for migrations with status 'applied', not 'pending'. For concurrency control (checking if a migration is pending or applied), use IsMigrationPendingOrApplied instead.

func (*Tracker) IsMigrationPendingOrApplied

func (t *Tracker) IsMigrationPendingOrApplied(ctx interface{}, migrationID string) (bool, error)

IsMigrationPendingOrApplied checks if a migration is pending or applied. For base migration IDs, migrations_list "pending" means registered-not-applied, not in-flight; this matches IsMigrationApplied (applied only). For schema-specific IDs, migrations_executions may hold status pending while a run is in progress.

func (*Tracker) RecordDependencyMigration

func (t *Tracker) RecordDependencyMigration(ctx interface{}, migration *state.MigrationRecord) error

RecordDependencyMigration records a dependency migration as applied without creating history entries. Requirement: Dependencies should only be recorded in the execution history of the migration that depends on them. This method marks the dependency as applied in migrations_list and migrations_executions but skips migrations_history.

func (*Tracker) RecordMigration

func (t *Tracker) RecordMigration(ctx interface{}, migration *state.MigrationRecord) error

RecordMigration records a migration execution

func (*Tracker) RecordSkippedMigrations

func (t *Tracker) RecordSkippedMigrations(ctx interface{}, skippedMigrationIDs []string, executedBy, executionMethod, executionContext string) error

RecordSkippedMigrations records skipped migrations for a given execution context

func (*Tracker) RegisterScannedMigration

func (t *Tracker) RegisterScannedMigration(ctx interface{}, migrationID, schema, table, version, name, connection, backend string) error

RegisterScannedMigration registers a scanned migration in migrations_list (status: pending)

func (*Tracker) ReindexMigrations

func (t *Tracker) ReindexMigrations(ctx interface{}, registry interface{}) error

ReindexMigrations reloads the BfM migration list and updates the database state This should be called asynchronously in the background

func (*Tracker) UpdateMigrationInfo

func (t *Tracker) UpdateMigrationInfo(ctx interface{}, migrationID, schema, table, version, name, connection, backend string) error

UpdateMigrationInfo updates migration metadata (schema, version, name, connection, backend) without affecting status/history

func (*Tracker) WithMigrationExecutionLock

func (t *Tracker) WithMigrationExecutionLock(ctx interface{}, migrationID, schema, connection string, fn func() error) error

WithMigrationExecutionLock runs fn while holding a session-level advisory lock on the state DB. The lock is per (migration_id, execution schema, connection) so the same migration can run for different schemas concurrently.

Jump to

Keyboard shortcuts

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