Documentation
¶
Index ¶
- type Tracker
- func (t *Tracker) Close() error
- func (t *Tracker) DeleteMigration(ctx interface{}, migrationID string) error
- func (t *Tracker) GetLastMigrationVersion(ctx interface{}, schema, table string) (string, error)
- func (t *Tracker) GetMigrationDetail(ctx interface{}, migrationID string) (*state.MigrationDetail, error)
- func (t *Tracker) GetMigrationExecutions(ctx interface{}, migrationID string) ([]*state.MigrationExecution, error)
- func (t *Tracker) GetMigrationHistory(ctx interface{}, filters *state.MigrationFilters) ([]*state.MigrationRecord, error)
- func (t *Tracker) GetMigrationList(ctx interface{}, filters *state.MigrationFilters) ([]*state.MigrationListItem, error)
- func (t *Tracker) GetRecentExecutions(ctx interface{}, limit int) ([]*state.MigrationExecution, error)
- func (t *Tracker) GetSkippedMigrations(ctx interface{}, migrationID string, limit int) ([]*state.SkippedMigration, error)
- func (t *Tracker) Initialize(ctx interface{}) error
- func (t *Tracker) IsMigrationApplied(ctx interface{}, migrationID string) (bool, error)
- func (t *Tracker) IsMigrationPendingOrApplied(ctx interface{}, migrationID string) (bool, error)
- func (t *Tracker) RecordDependencyMigration(ctx interface{}, migration *state.MigrationRecord) error
- func (t *Tracker) RecordMigration(ctx interface{}, migration *state.MigrationRecord) error
- func (t *Tracker) RecordSkippedMigrations(ctx interface{}, skippedMigrationIDs []string, ...) error
- func (t *Tracker) RegisterScannedMigration(ctx interface{}, ...) error
- func (t *Tracker) ReindexMigrations(ctx interface{}, registry interface{}) error
- func (t *Tracker) UpdateMigrationInfo(ctx interface{}, ...) error
- func (t *Tracker) WithMigrationExecutionLock(ctx interface{}, migrationID, schema, connection string, fn func() error) error
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 ¶
NewTracker creates a new PostgreSQL state tracker
func (*Tracker) DeleteMigration ¶
DeleteMigration deletes a migration from migrations_list (cascades to history via foreign key)
func (*Tracker) GetLastMigrationVersion ¶
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 ¶
Initialize creates the migration state tables
func (*Tracker) IsMigrationApplied ¶
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 ¶
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 ¶
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.