Documentation
¶
Index ¶
- type PostgresDriver
- func (p *PostgresDriver) Apply(ctx context.Context, payload driver.MigrationPayload) error
- func (p *PostgresDriver) Close(ctx context.Context) error
- func (p *PostgresDriver) DropAll(ctx context.Context) error
- func (p *PostgresDriver) DryRun(ctx context.Context, payload driver.MigrationPayload) error
- func (p *PostgresDriver) ExecuteSeed(ctx context.Context, rawSQL string) error
- func (p *PostgresDriver) GetAppliedMigrations(ctx context.Context) ([]driver.MigrationRecord, error)
- func (p *PostgresDriver) Initialize(ctx context.Context, connectionURL string) error
- func (p *PostgresDriver) Revert(ctx context.Context, payload driver.MigrationPayload) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PostgresDriver ¶
type PostgresDriver struct {
// contains filtered or unexported fields
}
PostgresDriver implements the driver.DatabaseDriver interface for PostgreSQL.
func (*PostgresDriver) Apply ¶
func (p *PostgresDriver) Apply(ctx context.Context, payload driver.MigrationPayload) error
Apply executes the UP migration in a single transaction to prevent dirty states.
func (*PostgresDriver) Close ¶
func (p *PostgresDriver) Close(ctx context.Context) error
Close gracefully closes the database connection.
func (*PostgresDriver) DropAll ¶
func (p *PostgresDriver) DropAll(ctx context.Context) error
DropAll completely wipes the database schema. USE WITH EXTREME CAUTION.
func (*PostgresDriver) DryRun ¶
func (p *PostgresDriver) DryRun(ctx context.Context, payload driver.MigrationPayload) error
DryRun executes the migration inside a transaction but forces a rollback at the end. This validates the SQL syntax and constraints without altering the database state.
func (*PostgresDriver) ExecuteSeed ¶
func (p *PostgresDriver) ExecuteSeed(ctx context.Context, rawSQL string) error
ExecuteSeed runs raw SQL within a transaction without tracking its state. Ideal for idempotent data seeding operations.
func (*PostgresDriver) GetAppliedMigrations ¶
func (p *PostgresDriver) GetAppliedMigrations(ctx context.Context) ([]driver.MigrationRecord, error)
GetAppliedMigrations fetches the history of successful migrations from the database. This is used by the Engine to determine which files in the directory are pending.
func (*PostgresDriver) Initialize ¶
func (p *PostgresDriver) Initialize(ctx context.Context, connectionURL string) error
Initialize connects to the database and ensures the migration metadata table exists.
func (*PostgresDriver) Revert ¶
func (p *PostgresDriver) Revert(ctx context.Context, payload driver.MigrationPayload) error
Revert executes the DOWN migration in a single transaction. It removes the schema changes and deletes the metadata record simultaneously.