Documentation
¶
Index ¶
- type Migration
- type MigrationRunner
- func (r *MigrationRunner) ApplyMigration(ctx context.Context, migration Migration) error
- func (r *MigrationRunner) ApplyMigrations(ctx context.Context, migrations []Migration) (int, error)
- func (r *MigrationRunner) EnsureMigrationTable(ctx context.Context) error
- func (r *MigrationRunner) GetAppliedMigrations(ctx context.Context) (map[string]bool, error)
- func (r *MigrationRunner) GetMigrationStatus(ctx context.Context, availableMigrations []Migration) ([]MigrationStatus, error)
- type MigrationStatus
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 ¶
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 ¶
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 ¶
MigrationStatus represents the status of a migration