Documentation
¶
Overview ¶
Package pgx implements the Driver interface.
Index ¶
- func Conn(c *pgx.Conn) driver.CopyConn
- func MigrateSchemas(ctx context.Context, migrators ...MigratableDatabase) error
- func New(tableName string) driver.DumpDriver
- func WithTransaction(ctx context.Context, tx driver.Tx, fn func() error) (err error)
- type MigratableDatabase
- type Row
- type Rows
- type SchemaMigrator
- func (m *SchemaMigrator) Drop(ctx context.Context) error
- func (m *SchemaMigrator) Dump(ctx context.Context, dw file.DumpWriter) (err error)
- func (m *SchemaMigrator) FinishRestore(ctx context.Context, migrator migrate.Migrator, schemas []string) error
- func (m *SchemaMigrator) GetPool() *pgxpool.Pool
- func (m *SchemaMigrator) InitCopy(ctx context.Context, schemaSuffix string, d driver.DumpDriver, ...) SchemaMigrator
- func (m *SchemaMigrator) Migrate(ctx context.Context) (schema string, fromVersion, toVersion file.Version, err error)
- func (m *SchemaMigrator) Path() string
- func (m *SchemaMigrator) Restore(ctx context.Context, dr file.DumpReader) error
- func (m *SchemaMigrator) Revert(ctx context.Context) error
- func (m *SchemaMigrator) Schema() string
- func (m *SchemaMigrator) StartRestore() (migrator migrate.Migrator, schemas []string)
- func (m *SchemaMigrator) StartRevert() (migrator migrate.Migrator, schemas []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateSchemas ¶ added in v1.4.0
func MigrateSchemas(ctx context.Context, migrators ...MigratableDatabase) error
MigrateSchemas migrates all the passed in migratable databases
Types ¶
type MigratableDatabase ¶
type MigratableDatabase interface { GetPool() *pgxpool.Pool Schema() string Path() string Migrate(ctx context.Context) (schema string, fromVersion, toVersion file.Version, err error) Dump(context.Context, file.DumpWriter) error Restore(context.Context, file.DumpReader) error Revert(ctx context.Context) error }
MigratableDatabase interface
type Row ¶
Row wraps *pgx.Row which is a convenience wrapper over *pgx.Rows
type SchemaMigrator ¶
SchemaMigrator struct
func (*SchemaMigrator) Drop ¶
func (m *SchemaMigrator) Drop(ctx context.Context) error
Drop rotates the schema to _bak and creates a new schema
func (*SchemaMigrator) Dump ¶
func (m *SchemaMigrator) Dump(ctx context.Context, dw file.DumpWriter) (err error)
Dump write the database to the DumpWriter
func (*SchemaMigrator) FinishRestore ¶
func (m *SchemaMigrator) FinishRestore(ctx context.Context, migrator migrate.Migrator, schemas []string) error
FinishRestore finishes the restore by rotating the schemas
func (*SchemaMigrator) GetPool ¶ added in v1.5.1
func (m *SchemaMigrator) GetPool() *pgxpool.Pool
Pool returns connection pool
func (*SchemaMigrator) InitCopy ¶
func (m *SchemaMigrator) InitCopy(ctx context.Context, schemaSuffix string, d driver.DumpDriver, newPool func(string) *pgxpool.Pool, ensureSchema bool) SchemaMigrator
InitCopy makes a copy and initializes it
func (*SchemaMigrator) Migrate ¶
func (m *SchemaMigrator) Migrate(ctx context.Context) (schema string, fromVersion, toVersion file.Version, err error)
Migrate migrate between schema versions
func (*SchemaMigrator) Restore ¶
func (m *SchemaMigrator) Restore(ctx context.Context, dr file.DumpReader) error
Restore restores the database from the passed in DumpReader
func (*SchemaMigrator) Revert ¶
func (m *SchemaMigrator) Revert(ctx context.Context) error
Revert reverts the database to the previous version
func (*SchemaMigrator) Schema ¶
func (m *SchemaMigrator) Schema() string
Schema returns the base schema
func (*SchemaMigrator) StartRestore ¶
func (m *SchemaMigrator) StartRestore() (migrator migrate.Migrator, schemas []string)
StartRestore creates a migrator and schemas used during restore
func (*SchemaMigrator) StartRevert ¶
func (m *SchemaMigrator) StartRevert() (migrator migrate.Migrator, schemas []string)
StartRevert creates a migrator and schemas used during revert