migrations

package
v0.167.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	// Version is the migration version (e.g., "001", "002")
	Version string
	// Description is a human-readable description of the migration
	Description string
	// UpSQL contains the SQL statements to apply the migration
	UpSQL string
	// DownSQL contains the SQL statements to rollback the migration (optional)
	DownSQL string
}

Migration represents a database migration

func GetPostgresMigrations

func GetPostgresMigrations() []Migration

GetPostgresMigrations returns all PostgreSQL migrations in order.

The schema mirrors GetSQLiteMigrations one-for-one (single conversations table with messages stored as an embedded JSON blob) so both dialects share the same SQL core (see issue #839); only the column types differ (TIMESTAMP WITH TIME ZONE for datetimes). JSON columns are TEXT because the application marshals/unmarshals JSON itself — switch to JSONB only if server-side JSON querying is ever needed.

func GetSQLiteMigrations

func GetSQLiteMigrations() []Migration

GetSQLiteMigrations returns all SQLite migrations in order

type MigrationRunner

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

MigrationRunner manages database migrations

func NewMigrationRunner

func NewMigrationRunner(db *sql.DB, dialect string) *MigrationRunner

NewMigrationRunner creates a new migration runner

func (*MigrationRunner) ApplyMigration

func (r *MigrationRunner) ApplyMigration(ctx context.Context, migration Migration) error

ApplyMigration applies a single migration

func (*MigrationRunner) ApplyMigrations

func (r *MigrationRunner) ApplyMigrations(ctx context.Context, migrations []Migration) (int, error)

ApplyMigrations applies all pending migrations

func (*MigrationRunner) EnsureMigrationTable

func (r *MigrationRunner) EnsureMigrationTable(ctx context.Context) error

EnsureMigrationTable creates the migration tracking table if it doesn't exist

func (*MigrationRunner) GetAppliedMigrations

func (r *MigrationRunner) GetAppliedMigrations(ctx context.Context) (map[string]bool, error)

GetAppliedMigrations returns a list of applied migration versions

func (*MigrationRunner) GetMigrationStatus

func (r *MigrationRunner) GetMigrationStatus(ctx context.Context, availableMigrations []Migration) ([]MigrationStatus, error)

GetMigrationStatus returns the current migration status

type MigrationStatus

type MigrationStatus struct {
	Version     string
	Description string
	Applied     bool
}

MigrationStatus represents the status of a migration

Jump to

Keyboard shortcuts

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