Documentation
¶
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (c *Client) ExecBatch(ctx context.Context, queries []string, args [][]any) error
- func (c *Client) ExecTx(ctx context.Context, fn func(pgx.Tx) error) error
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Pool() *pgxpool.Pool
- func (c *Client) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func (c *Client) QueryRows(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- type Config
- type Migration
- type MigrationManager
- func (m *MigrationManager) ApplyMigration(ctx context.Context, migration Migration) error
- func (m *MigrationManager) GetAppliedMigrations(ctx context.Context) (map[int]time.Time, error)
- func (m *MigrationManager) InitMigrationTable(ctx context.Context) error
- func (m *MigrationManager) Migrate(ctx context.Context, migrations []Migration) error
- func (m *MigrationManager) RollbackLastMigration(ctx context.Context, rollbacks map[int]string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientFromEnv ¶
func NewClientFromEnv() *Client
type Migration ¶
func LoadMigrationsFromPath ¶
LoadMigrationsFromPath loads migrations from SQL files in the specified directory path. The function expects SQL files to be named with the pattern: {version}_{description}.sql where version is a numeric identifier and description is the migration description. example: 001_create_users.sql
type MigrationManager ¶
type MigrationManager struct {
// contains filtered or unexported fields
}
func NewMigrationManager ¶
func NewMigrationManager(client *Client) *MigrationManager
func (*MigrationManager) ApplyMigration ¶
func (m *MigrationManager) ApplyMigration(ctx context.Context, migration Migration) error
func (*MigrationManager) GetAppliedMigrations ¶
func (*MigrationManager) InitMigrationTable ¶
func (m *MigrationManager) InitMigrationTable(ctx context.Context) error
func (*MigrationManager) Migrate ¶
func (m *MigrationManager) Migrate(ctx context.Context, migrations []Migration) error
func (*MigrationManager) RollbackLastMigration ¶
Click to show internal directories.
Click to hide internal directories.