repository

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 (c *Clickhouse) CreateMigrationHistoryTable(ctx context.Context) error

CreateMigrationHistoryTable creates a new migration history table.

func (*Clickhouse) DropMigrationHistoryTable

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

DropMigrationHistoryTable drops the migration history table.

func (*Clickhouse) ExecQuery

func (c *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 (c *Clickhouse) ExecQueryTransaction(ctx context.Context, txFn func(ctx context.Context) error) error

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

func (*Clickhouse) ForceSafely

func (c *Clickhouse) ForceSafely() bool

func (*Clickhouse) HasMigrationHistoryTable

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

HasMigrationHistoryTable returns true if migration history table exists.

func (*Clickhouse) InsertMigration

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

InsertMigration inserts the new migration record.

func (*Clickhouse) Migrations

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

Migrations returns applied migrations history.

func (*Clickhouse) MigrationsCount

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

MigrationsCount returns the number of migrations

func (*Clickhouse) RemoveMigration

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

RemoveMigration removes the migration record.

func (*Clickhouse) TableNameWithSchema

func (c *Clickhouse) TableNameWithSchema() string

type Connection

type Connection interface {
	DSN() string
	Driver() connection.Driver
	Ping() error
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.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
}

func (*DBError) Error

func (d *DBError) Error() string

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) ForceSafely

func (m *MySQL) ForceSafely() bool

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) 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 Options

type Options struct {
	TableName   string
	SchemaName  string
	ClusterName string
	ShardName   string
}

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) ForceSafely

func (p *Postgres) ForceSafely() bool

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) 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 Repository

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

func New

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

New creates repository by connection

func (*Repository) CreateMigrationHistoryTable

func (r *Repository) CreateMigrationHistoryTable(ctx context.Context) error

func (*Repository) DropMigrationHistoryTable

func (r *Repository) DropMigrationHistoryTable(ctx context.Context) error

func (*Repository) ExecQuery

func (r *Repository) ExecQuery(ctx context.Context, query string, args ...any) error

func (*Repository) ExecQueryTransaction

func (r *Repository) ExecQueryTransaction(ctx context.Context, fnTx func(ctx context.Context) error) error

func (*Repository) ForceSafely

func (r *Repository) ForceSafely() bool

func (*Repository) HasMigrationHistoryTable

func (r *Repository) HasMigrationHistoryTable(ctx context.Context) (exists bool, err error)

func (*Repository) InsertMigration

func (r *Repository) InsertMigration(ctx context.Context, version string) error

func (*Repository) Migrations

func (r *Repository) Migrations(ctx context.Context, limit int) (entity.Migrations, error)

func (*Repository) MigrationsCount

func (r *Repository) MigrationsCount(ctx context.Context) (int, error)

func (*Repository) RemoveMigration

func (r *Repository) RemoveMigration(ctx context.Context, version string) error

func (*Repository) TableNameWithSchema

func (r *Repository) TableNameWithSchema() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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