store

package
v0.0.0-...-f34691d Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migration

type Migration struct {
	Version   int64     `json:"version"`
	IsApplied bool      `json:"is_applied"`
	CreatedAt time.Time `json:"created_at"`
}

type Store

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

func NewStore

func NewStore(tableName string, esClient *elasticsearch.TypedClient) *Store

func (*Store) CreateVersionTable

func (s *Store) CreateVersionTable(ctx context.Context, _ database.DBTxConn) error

CreateVersionTable creates the version table, which is used to track migrations.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, _ database.DBTxConn, version int64) error

Delete removes a version id from the version table.

func (*Store) GetLatestVersion

func (s *Store) GetLatestVersion(ctx context.Context, _ database.DBTxConn) (int64, error)

GetLatestVersion retrieves the last applied migration version. If no migrations exist, this method must return [ErrVersionNotFound].

func (*Store) GetMigration

func (s *Store) GetMigration(
	ctx context.Context,
	_ database.DBTxConn,
	version int64,
) (*database.GetMigrationResult, error)

GetMigration retrieves a single migration by version id. If the query succeeds, but the version is not found, this method must return [ErrVersionNotFound].

func (*Store) Insert

Insert a version id into the version table.

func (*Store) ListMigrations

func (s *Store) ListMigrations(ctx context.Context, _ database.DBTxConn) ([]*database.ListMigrationsResult, error)

ListMigrations retrieves all migrations sorted in descending order by id or timestamp. If there are no migrations, return empty slice with no error. Typically this method will return at least one migration, because the initial version (0) is always inserted into the version table when it is created.

func (*Store) Tablename

func (s *Store) Tablename() string

Jump to

Keyboard shortcuts

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