Documentation
¶
Index ¶
- type CLIManager
- func (cm *CLIManager) CreateMigration(name string) error
- func (cm *CLIManager) CreateMigrationsDirectory() error
- func (cm *CLIManager) Down(ctx context.Context) error
- func (cm *CLIManager) LoadMigrations() ([]Migration, error)
- func (cm *CLIManager) Reset(ctx context.Context) error
- func (cm *CLIManager) SetMigrationTableName(tableName string) error
- func (cm *CLIManager) Status(ctx context.Context) error
- func (cm *CLIManager) Up(ctx context.Context) error
- func (cm *CLIManager) Validate() error
- type Migration
- type MigrationManager
- func (mm *MigrationManager) ApplyMigration(ctx context.Context, migration Migration) error
- func (mm *MigrationManager) GetAppliedMigrations(ctx context.Context) ([]Migration, error)
- func (mm *MigrationManager) GetMigrationStatus(ctx context.Context, availableMigrations []Migration) ([]MigrationStatus, error)
- func (mm *MigrationManager) Initialize(ctx context.Context) error
- func (mm *MigrationManager) IsMigrationApplied(ctx context.Context, version string) (bool, error)
- func (mm *MigrationManager) RollbackMigration(ctx context.Context, migration Migration) error
- func (mm *MigrationManager) SetTableName(table string) error
- type MigrationStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLIManager ¶
type CLIManager struct {
// contains filtered or unexported fields
}
CLIManager handles CLI operations for migrations
func NewCLIManager ¶
func NewCLIManager(provider database.DatabaseProvider, migrationsDir string, logger *logrus.Logger) *CLIManager
NewCLIManager creates a new CLI manager
func (*CLIManager) CreateMigration ¶
func (cm *CLIManager) CreateMigration(name string) error
CreateMigration creates a new migration file
func (*CLIManager) CreateMigrationsDirectory ¶
func (cm *CLIManager) CreateMigrationsDirectory() error
CreateMigrationsDirectory creates the migrations directory if it doesn't exist
func (*CLIManager) Down ¶
func (cm *CLIManager) Down(ctx context.Context) error
Down rolls back the last migration
func (*CLIManager) LoadMigrations ¶
func (cm *CLIManager) LoadMigrations() ([]Migration, error)
LoadMigrations loads all migration files from the migrations directory
func (*CLIManager) Reset ¶
func (cm *CLIManager) Reset(ctx context.Context) error
Reset drops all tables and reapplies all migrations
func (*CLIManager) SetMigrationTableName ¶
func (cm *CLIManager) SetMigrationTableName(tableName string) error
SetMigrationTableName sets the migration table name with validation
func (*CLIManager) Status ¶
func (cm *CLIManager) Status(ctx context.Context) error
Status shows the status of all migrations
func (*CLIManager) Up ¶
func (cm *CLIManager) Up(ctx context.Context) error
Up applies all pending migrations
func (*CLIManager) Validate ¶
func (cm *CLIManager) Validate() error
Validate checks if all migration files are valid
type Migration ¶
type Migration struct {
Version string `json:"version"`
Description string `json:"description"`
UpSQL string `json:"up_sql"`
DownSQL string `json:"down_sql"`
CreatedAt time.Time `json:"created_at"`
AppliedAt *time.Time `json:"applied_at,omitempty"`
Checksum string `json:"checksum"`
}
Migration represents a database migration
type MigrationManager ¶
type MigrationManager struct {
// contains filtered or unexported fields
}
MigrationManager manages database migrations
func NewMigrationManager ¶
func NewMigrationManager(provider database.DatabaseProvider, logger *logrus.Logger) *MigrationManager
NewMigrationManager creates a new migration manager
func (*MigrationManager) ApplyMigration ¶
func (mm *MigrationManager) ApplyMigration(ctx context.Context, migration Migration) error
ApplyMigration applies a migration
func (*MigrationManager) GetAppliedMigrations ¶
func (mm *MigrationManager) GetAppliedMigrations(ctx context.Context) ([]Migration, error)
GetAppliedMigrations returns a list of applied migrations
func (*MigrationManager) GetMigrationStatus ¶
func (mm *MigrationManager) GetMigrationStatus(ctx context.Context, availableMigrations []Migration) ([]MigrationStatus, error)
GetMigrationStatus returns the status of all migrations
func (*MigrationManager) Initialize ¶
func (mm *MigrationManager) Initialize(ctx context.Context) error
Initialize creates the migration table if it doesn't exist
func (*MigrationManager) IsMigrationApplied ¶
IsMigrationApplied checks if a migration is already applied
func (*MigrationManager) RollbackMigration ¶
func (mm *MigrationManager) RollbackMigration(ctx context.Context, migration Migration) error
RollbackMigration rolls back a migration
func (*MigrationManager) SetTableName ¶
func (mm *MigrationManager) SetTableName(table string) error
SetTableName sets the migration table name with validation