repository

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2025 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPtrValueMustBeAPointerAndScalar = errors.New("ptr value must be a pointer and scalar")
)

Functions

This section is empty.

Types

type Clickhouse

type Clickhouse struct {
	// contains filtered or unexported fields
}

func NewClickhouse

func NewClickhouse(conn Connection, options *Options) *Clickhouse

func (*Clickhouse) CreateMigrationHistoryTable

func (ch *Clickhouse) CreateMigrationHistoryTable(ctx context.Context) error

CreateMigrationHistoryTable creates a new migration history table.

func (*Clickhouse) DropMigrationHistoryTable

func (ch *Clickhouse) DropMigrationHistoryTable(ctx context.Context) error

DropMigrationHistoryTable drops the migration history table.

func (*Clickhouse) ExecQuery

func (ch *Clickhouse) ExecQuery(ctx context.Context, query string, args ...any) error

ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*Clickhouse) ExecQueryTransaction

func (ch *Clickhouse) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error

ExecQueryTransaction executes txFn in transaction. todo: называется ExecQuery но query не принимает. подумать

func (*Clickhouse) ExistsMigration added in v0.4.0

func (ch *Clickhouse) ExistsMigration(ctx context.Context, version string) (bool, error)

func (*Clickhouse) HasMigrationHistoryTable

func (ch *Clickhouse) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)

HasMigrationHistoryTable returns true if migration history table exists.

func (*Clickhouse) InsertMigration

func (ch *Clickhouse) InsertMigration(ctx context.Context, version string) error

InsertMigration inserts the new migration record.

func (*Clickhouse) Migrations

func (ch *Clickhouse) Migrations(ctx context.Context, limit int) (entity.Migrations, error)

Migrations returns applied migrations history.

func (*Clickhouse) MigrationsCount

func (ch *Clickhouse) MigrationsCount(ctx context.Context) (int, error)

MigrationsCount returns the number of migrations

func (*Clickhouse) QueryScalar added in v1.2.0

func (ch *Clickhouse) QueryScalar(ctx context.Context, query string, ptr any) error

func (*Clickhouse) RemoveMigration

func (ch *Clickhouse) RemoveMigration(ctx context.Context, version string) error

RemoveMigration removes the migration record.

func (*Clickhouse) TableNameWithSchema

func (ch *Clickhouse) TableNameWithSchema() string

type ClickhouseFactory added in v1.2.0

type ClickhouseFactory struct{}

func (*ClickhouseFactory) Create added in v1.2.0

func (f *ClickhouseFactory) Create(conn Connection, options *Options) (Repository, error)

func (*ClickhouseFactory) Supports added in v1.2.0

func (f *ClickhouseFactory) Supports(driver connection.Driver) bool

type Connection

type Connection interface {
	io.Closer

	DSN() string
	Driver() connection.Driver
	Ping() error
	QueryContext(ctx context.Context, query string, args ...any) (sqlex.Rows, error)
	ExecContext(ctx context.Context, query string, args ...any) (sqlex.Result, error)
	Transaction(ctx context.Context, txFn func(ctx context.Context) error) error
}

type DBError

type DBError struct {
	Code          string
	Severity      string
	Message       string
	Details       string
	InternalQuery string
	Cause         error
}

func (*DBError) Error

func (d *DBError) Error() string

func (*DBError) Unwrap added in v1.2.0

func (d *DBError) Unwrap() error

type Factory added in v1.2.0

type Factory interface {
	Create(conn Connection, options *Options) (Repository, error)
	Supports(driver connection.Driver) bool
}

type FactoryRegistry added in v1.2.0

type FactoryRegistry struct {
	// contains filtered or unexported fields
}

func NewFactoryRegistry added in v1.2.0

func NewFactoryRegistry() *FactoryRegistry

func (*FactoryRegistry) Create added in v1.2.0

func (r *FactoryRegistry) Create(conn Connection, options *Options) (Repository, error)

type MySQL

type MySQL struct {
	// contains filtered or unexported fields
}

func NewMySQL

func NewMySQL(conn Connection, options *Options) *MySQL

func (*MySQL) CreateMigrationHistoryTable

func (m *MySQL) CreateMigrationHistoryTable(ctx context.Context) error

CreateMigrationHistoryTable creates a new migration history table.

func (*MySQL) DropMigrationHistoryTable

func (m *MySQL) DropMigrationHistoryTable(ctx context.Context) error

DropMigrationHistoryTable drops the migration history table.

func (*MySQL) ExecQuery

func (m *MySQL) ExecQuery(ctx context.Context, query string, args ...any) error

ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*MySQL) ExecQueryTransaction

func (m *MySQL) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error

ExecQueryTransaction executes a query in transaction without returning any rows. The args are for any placeholder parameters in the query.

func (*MySQL) ExistsMigration added in v0.4.0

func (m *MySQL) ExistsMigration(ctx context.Context, version string) (bool, error)

func (*MySQL) HasMigrationHistoryTable

func (m *MySQL) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)

HasMigrationHistoryTable returns true if migration history table exists.

func (*MySQL) InsertMigration

func (m *MySQL) InsertMigration(ctx context.Context, version string) error

InsertMigration inserts the new migration record.

func (*MySQL) Migrations

func (m *MySQL) Migrations(ctx context.Context, limit int) (entity.Migrations, error)

Migrations returns applied migrations history.

func (*MySQL) MigrationsCount

func (m *MySQL) MigrationsCount(ctx context.Context) (int, error)

MigrationsCount returns the number of migrations

func (*MySQL) QueryScalar added in v1.2.0

func (m *MySQL) QueryScalar(ctx context.Context, query string, ptr any) error

func (*MySQL) RemoveMigration

func (m *MySQL) RemoveMigration(ctx context.Context, version string) error

RemoveMigration removes the migration record.

func (*MySQL) TableNameWithSchema

func (m *MySQL) TableNameWithSchema() string

type MySQLFactory added in v1.2.0

type MySQLFactory struct{}

func (*MySQLFactory) Create added in v1.2.0

func (f *MySQLFactory) Create(conn Connection, options *Options) (Repository, error)

func (*MySQLFactory) Supports added in v1.2.0

func (f *MySQLFactory) Supports(driver connection.Driver) bool

type Options

type Options struct {
	TableName   string
	SchemaName  string
	ClusterName string
	Replicated  bool
}

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

func NewPostgres

func NewPostgres(conn Connection, options *Options) *Postgres

func (*Postgres) CreateMigrationHistoryTable

func (p *Postgres) CreateMigrationHistoryTable(ctx context.Context) error

CreateMigrationHistoryTable creates a new migration history table.

func (*Postgres) DropMigrationHistoryTable

func (p *Postgres) DropMigrationHistoryTable(ctx context.Context) error

DropMigrationHistoryTable drops the migration history table.

func (*Postgres) ExecQuery

func (p *Postgres) ExecQuery(ctx context.Context, query string, args ...any) error

ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*Postgres) ExecQueryTransaction

func (p *Postgres) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error

ExecQueryTransaction executes a query in transaction without returning any rows. The args are for any placeholder parameters in the query.

func (*Postgres) ExistsMigration added in v0.4.0

func (p *Postgres) ExistsMigration(ctx context.Context, version string) (bool, error)

func (*Postgres) HasMigrationHistoryTable

func (p *Postgres) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)

HasMigrationHistoryTable returns true if migration history table exists.

func (*Postgres) InsertMigration

func (p *Postgres) InsertMigration(ctx context.Context, version string) error

InsertMigration inserts the new migration record.

func (*Postgres) Migrations

func (p *Postgres) Migrations(ctx context.Context, limit int) (entity.Migrations, error)

Migrations returns applied migrations history.

func (*Postgres) MigrationsCount

func (p *Postgres) MigrationsCount(ctx context.Context) (int, error)

MigrationsCount returns the number of migrations

func (*Postgres) QueryScalar added in v1.2.0

func (p *Postgres) QueryScalar(ctx context.Context, query string, ptr any) error

func (*Postgres) RemoveMigration

func (p *Postgres) RemoveMigration(ctx context.Context, version string) error

RemoveMigration removes the migration record.

func (*Postgres) TableNameWithSchema

func (p *Postgres) TableNameWithSchema() string

type PostgresFactory added in v1.2.0

type PostgresFactory struct{}

func (*PostgresFactory) Create added in v1.2.0

func (f *PostgresFactory) Create(conn Connection, options *Options) (Repository, error)

func (*PostgresFactory) Supports added in v1.2.0

func (f *PostgresFactory) Supports(driver connection.Driver) bool

type Repository

type Repository interface {
	Migrations(ctx context.Context, limit int) (entity.Migrations, error)
	HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)
	InsertMigration(ctx context.Context, version string) error
	RemoveMigration(ctx context.Context, version string) error
	ExecQuery(ctx context.Context, query string, args ...any) error
	QueryScalar(ctx context.Context, query string, ptr any) error
	ExecQueryTransaction(ctx context.Context, fnTx func(ctx context.Context) error) error
	DropMigrationHistoryTable(ctx context.Context) error
	CreateMigrationHistoryTable(ctx context.Context) error
	MigrationsCount(ctx context.Context) (int, error)
	ExistsMigration(ctx context.Context, version string) (bool, error)
	TableNameWithSchema() string
}

func New

func New(conn Connection, options *Options) (Repository, error)

New creates repository by connection

type Tarantool added in v1.2.0

type Tarantool struct {
	// contains filtered or unexported fields
}

func NewTarantool added in v1.2.0

func NewTarantool(conn Connection, options *Options) *Tarantool

func (*Tarantool) CreateMigrationHistoryTable added in v1.2.0

func (p *Tarantool) CreateMigrationHistoryTable(ctx context.Context) error

CreateMigrationHistoryTable creates a new migration history table.

func (*Tarantool) DropMigrationHistoryTable added in v1.2.0

func (p *Tarantool) DropMigrationHistoryTable(ctx context.Context) error

DropMigrationHistoryTable drops the migration history table.

func (*Tarantool) ExecQuery added in v1.2.0

func (p *Tarantool) ExecQuery(ctx context.Context, query string, args ...any) error

ExecQuery executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*Tarantool) ExecQueryTransaction added in v1.2.0

func (p *Tarantool) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error

ExecQueryTransaction executes a query in transaction without returning any rows. The args are for any placeholder parameters in the query.

func (*Tarantool) ExistsMigration added in v1.2.0

func (p *Tarantool) ExistsMigration(ctx context.Context, version string) (bool, error)

func (*Tarantool) HasMigrationHistoryTable added in v1.2.0

func (p *Tarantool) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)

HasMigrationHistoryTable returns true if migration history table exists.

func (*Tarantool) InsertMigration added in v1.2.0

func (p *Tarantool) InsertMigration(ctx context.Context, version string) error

InsertMigration inserts the new migration record.

func (*Tarantool) Migrations added in v1.2.0

func (p *Tarantool) Migrations(ctx context.Context, limit int) (entity.Migrations, error)

Migrations returns applied migrations history.

func (*Tarantool) MigrationsCount added in v1.2.0

func (p *Tarantool) MigrationsCount(ctx context.Context) (int, error)

MigrationsCount returns the number of migrations

func (*Tarantool) QueryScalar added in v1.2.0

func (p *Tarantool) QueryScalar(ctx context.Context, query string, ptr any) error

QueryScalar returns the number of records by query

func (*Tarantool) RemoveMigration added in v1.2.0

func (p *Tarantool) RemoveMigration(ctx context.Context, version string) error

RemoveMigration removes the migration record.

func (*Tarantool) TableNameWithSchema added in v1.2.0

func (p *Tarantool) TableNameWithSchema() string

type TarantoolFactory added in v1.2.0

type TarantoolFactory struct{}

func (*TarantoolFactory) Create added in v1.2.0

func (f *TarantoolFactory) Create(conn Connection, options *Options) (Repository, error)

func (*TarantoolFactory) Supports added in v1.2.0

func (f *TarantoolFactory) Supports(driver connection.Driver) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL