ent

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 15 Imported by: 0

README

ent

import "github.com/aws-contrib/aws-aurora/internal/database/ent"

Package ent provides an extension to the ent package for database operations.

Index

Variables

var (
    // ErrTooManyRows occurs when more rows than expected are returned.
    ErrTooManyRows = pgx.ErrTooManyRows
    // ErrNoRows occurs when rows are expected but none are returned.
    ErrNoRows = pgx.ErrNoRows
)

var ErrCodeUniqueViolation = pgerrcode.UniqueViolation

Mutex is a special revision that represents a lock on the database.

var Mutex = &Revision{
    ID:          "20060102150405",
    Description: "lock",
}

func IsErrorCode

func IsErrorCode(err error, code string) bool

IsErrorCode reports whether the error is a PostgreSQL error with the given code.

func IsErrorNotFound

func IsErrorNotFound(err error) bool

IsErrorNotFound reports whether the error is a "not found" error.

func WithURL

func WithURL() string

WithURL returns the database URL.

type ApplyMigrationParams

ApplyMigrationParams represents the parameters for executing a revision.

type ApplyMigrationParams struct {
    // Migration contains the parameters for executing a migration.
    Migration *Migration
}

type Batch

Batch represents a batch of results.

type Batch struct {
    Results pgx.BatchResults
    Total   int
}

type DBTX

type DBTX interface {
    Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
    Query(context.Context, string, ...interface{}) (pgx.Rows, error)
    QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteJobParams

type DeleteJobParams struct {
    JobID string `db:"job_id" json:"job_id"`
}

func (*DeleteJobParams) SetJob
func (x *DeleteJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type DeleteJobParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type DeleteJobParamsConverter interface {
    // goverter:update target
    SetFromJob(target *DeleteJobParams, source *Job)
}

type DeleteJobParamsConverterImpl

type DeleteJobParamsConverterImpl struct{}

func (*DeleteJobParamsConverterImpl) SetFromJob
func (c *DeleteJobParamsConverterImpl) SetFromJob(target *DeleteJobParams, source *Job)

type DeleteLockParams

type DeleteLockParams struct {
    ID string `db:"id" json:"id"`
}

func (*DeleteLockParams) SetLock
func (x *DeleteLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type DeleteLockParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type DeleteLockParamsConverter interface {
    // goverter:update target
    SetFromLock(target *DeleteLockParams, source *Lock)
}

type DeleteLockParamsConverterImpl

type DeleteLockParamsConverterImpl struct{}

func (*DeleteLockParamsConverterImpl) SetFromLock
func (c *DeleteLockParamsConverterImpl) SetFromLock(target *DeleteLockParams, source *Lock)

type DeleteRevisionParams

type DeleteRevisionParams struct {
    ID string `db:"id" json:"id"`
}

func (*DeleteRevisionParams) SetRevision
func (x *DeleteRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type DeleteRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type DeleteRevisionParamsConverter interface {
    // goverter:update target
    SetFromRevision(target *DeleteRevisionParams, source *Revision)
}

type DeleteRevisionParamsConverterImpl

type DeleteRevisionParamsConverterImpl struct{}

func (*DeleteRevisionParamsConverterImpl) SetFromRevision
func (c *DeleteRevisionParamsConverterImpl) SetFromRevision(target *DeleteRevisionParams, source *Revision)

type Error

PgError represents an error reported by the PostgreSQL server.

type Error = pgconn.PgError

type ExecDeleteJobParams

type ExecDeleteJobParams struct {
    JobID string `db:"job_id" json:"job_id"`
}

func (*ExecDeleteJobParams) SetJob
func (x *ExecDeleteJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type ExecDeleteJobParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecDeleteJobParamsConverter interface {
    // goverter:update target
    SetFromJob(target *ExecDeleteJobParams, source *Job)
}

type ExecDeleteJobParamsConverterImpl

type ExecDeleteJobParamsConverterImpl struct{}

func (*ExecDeleteJobParamsConverterImpl) SetFromJob
func (c *ExecDeleteJobParamsConverterImpl) SetFromJob(target *ExecDeleteJobParams, source *Job)

type ExecDeleteLockParams

type ExecDeleteLockParams struct {
    ID string `db:"id" json:"id"`
}

func (*ExecDeleteLockParams) SetLock
func (x *ExecDeleteLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type ExecDeleteLockParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecDeleteLockParamsConverter interface {
    // goverter:update target
    SetFromLock(target *ExecDeleteLockParams, source *Lock)
}

type ExecDeleteLockParamsConverterImpl

type ExecDeleteLockParamsConverterImpl struct{}

func (*ExecDeleteLockParamsConverterImpl) SetFromLock
func (c *ExecDeleteLockParamsConverterImpl) SetFromLock(target *ExecDeleteLockParams, source *Lock)

type ExecDeleteRevisionParams

type ExecDeleteRevisionParams struct {
    ID string `db:"id" json:"id"`
}

func (*ExecDeleteRevisionParams) SetRevision
func (x *ExecDeleteRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecDeleteRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecDeleteRevisionParamsConverter interface {
    // goverter:update target
    SetFromRevision(target *ExecDeleteRevisionParams, source *Revision)
}

type ExecDeleteRevisionParamsConverterImpl

type ExecDeleteRevisionParamsConverterImpl struct{}

func (*ExecDeleteRevisionParamsConverterImpl) SetFromRevision
func (c *ExecDeleteRevisionParamsConverterImpl) SetFromRevision(target *ExecDeleteRevisionParams, source *Revision)

type ExecInsertJobParams

type ExecInsertJobParams struct {
    JobID   string  `db:"job_id" json:"job_id"`
    Status  string  `db:"status" json:"status"`
    Details *string `db:"details" json:"details"`
}

func (*ExecInsertJobParams) SetJob
func (x *ExecInsertJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type ExecInsertJobParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecInsertJobParamsConverter interface {
    // goverter:update target
    SetFromJob(target *ExecInsertJobParams, source *Job)
}

type ExecInsertJobParamsConverterImpl

type ExecInsertJobParamsConverterImpl struct{}

func (*ExecInsertJobParamsConverterImpl) SetFromJob
func (c *ExecInsertJobParamsConverterImpl) SetFromJob(target *ExecInsertJobParams, source *Job)

type ExecInsertLockParams

type ExecInsertLockParams struct {
    ID        string    `db:"id" json:"id"`
    CreatedAt time.Time `db:"created_at" json:"created_at"`
}

func (*ExecInsertLockParams) SetLock
func (x *ExecInsertLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type ExecInsertLockParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecInsertLockParamsConverter interface {
    // goverter:update target
    SetFromLock(target *ExecInsertLockParams, source *Lock)
}

type ExecInsertLockParamsConverterImpl

type ExecInsertLockParamsConverterImpl struct{}

func (*ExecInsertLockParamsConverterImpl) SetFromLock
func (c *ExecInsertLockParamsConverterImpl) SetFromLock(target *ExecInsertLockParams, source *Lock)

type ExecInsertRevisionParams

type ExecInsertRevisionParams struct {
    ID            string        `db:"id" json:"id"`
    Description   string        `db:"description" json:"description"`
    Total         int           `db:"total" json:"total"`
    Count         int           `db:"count" json:"count"`
    Error         *string       `db:"error" json:"error"`
    ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
    ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
    ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*ExecInsertRevisionParams) SetRevision
func (x *ExecInsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecInsertRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecInsertRevisionParamsConverter interface {
    // goverter:update target
    SetFromRevision(target *ExecInsertRevisionParams, source *Revision)
}

type ExecInsertRevisionParamsConverterImpl

type ExecInsertRevisionParamsConverterImpl struct{}

func (*ExecInsertRevisionParamsConverterImpl) SetFromRevision
func (c *ExecInsertRevisionParamsConverterImpl) SetFromRevision(target *ExecInsertRevisionParams, source *Revision)

type ExecUpdateRevisionParams

type ExecUpdateRevisionParams struct {
    UpdateMask    []string      `db:"update_mask" json:"update_mask"`
    Description   string        `db:"description" json:"description"`
    Total         int           `db:"total" json:"total"`
    Count         int           `db:"count" json:"count"`
    Error         *string       `db:"error" json:"error"`
    ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
    ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
    ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
    ID            string        `db:"id" json:"id"`
}

func (*ExecUpdateRevisionParams) SetRevision
func (x *ExecUpdateRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecUpdateRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecUpdateRevisionParamsConverter interface {
    // goverter:update target
    // goverter:ignore UpdateMask
    SetFromRevision(target *ExecUpdateRevisionParams, source *Revision)
}

type ExecUpdateRevisionParamsConverterImpl

type ExecUpdateRevisionParamsConverterImpl struct{}

func (*ExecUpdateRevisionParamsConverterImpl) SetFromRevision
func (c *ExecUpdateRevisionParamsConverterImpl) SetFromRevision(target *ExecUpdateRevisionParams, source *Revision)

type ExecUpsertRevisionParams

type ExecUpsertRevisionParams struct {
    ID            string        `db:"id" json:"id"`
    Description   string        `db:"description" json:"description"`
    Total         int           `db:"total" json:"total"`
    Count         int           `db:"count" json:"count"`
    Error         *string       `db:"error" json:"error"`
    ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
    ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
    ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*ExecUpsertRevisionParams) SetRevision
func (x *ExecUpsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecUpsertRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecUpsertRevisionParamsConverter interface {
    // goverter:update target
    SetFromRevision(target *ExecUpsertRevisionParams, source *Revision)
}

type ExecUpsertRevisionParamsConverterImpl

type ExecUpsertRevisionParamsConverterImpl struct{}

func (*ExecUpsertRevisionParamsConverterImpl) SetFromRevision
func (c *ExecUpsertRevisionParamsConverterImpl) SetFromRevision(target *ExecUpsertRevisionParams, source *Revision)

type FileSystem

FileSystem represents a filesystem that supports globbing and reading files.

type FileSystem interface {
    fs.FS
    fs.GlobFS
    fs.ReadFileFS
}

type Gateway

Gateway represents the database gateway.

type Gateway interface {
    // inherit from Querier
    Querier
    // Database returns the underlying transaction interface.
    Database() DBTX
    // RunInTx runs the given function in a transaction.
    RunInTx(context.Context, QuerierAction) error
    // Ping verifies a connection to the database is still alive.
    Ping(context.Context) error
    // Close closes the connection to the database.
    Close()
}

func Open
func Open(ctx context.Context, uri string, options ...GatewayOption) (_ Gateway, err error)

Open opens a database connection to the given URL.

type GatewayOption

GatewayOption represents a gateway option.

type GatewayOption interface {
    // Apply applies the configuration.
    Apply(*pgxpool.Config) error
}

type GatewayOptionFunc

GatewayOptionFunc is a function that applies a GatewayOption.

type GatewayOptionFunc func(*pgxpool.Config) error

func (GatewayOptionFunc) Apply
func (fn GatewayOptionFunc) Apply(cfg *pgxpool.Config) error

Apply applies the GatewayOptionFunc to the Gateway.

type GetJobParams

type GetJobParams struct {
    JobID string `db:"job_id" json:"job_id"`
}

func (*GetJobParams) SetJob
func (x *GetJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type GetJobParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type GetJobParamsConverter interface {
    // goverter:update target
    SetFromJob(target *GetJobParams, source *Job)
}

type GetJobParamsConverterImpl

type GetJobParamsConverterImpl struct{}

func (*GetJobParamsConverterImpl) SetFromJob
func (c *GetJobParamsConverterImpl) SetFromJob(target *GetJobParams, source *Job)

type GetLockParams

type GetLockParams struct {
    ID string `db:"id" json:"id"`
}

func (*GetLockParams) SetLock
func (x *GetLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type GetLockParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type GetLockParamsConverter interface {
    // goverter:update target
    SetFromLock(target *GetLockParams, source *Lock)
}

type GetLockParamsConverterImpl

type GetLockParamsConverterImpl struct{}

func (*GetLockParamsConverterImpl) SetFromLock
func (c *GetLockParamsConverterImpl) SetFromLock(target *GetLockParams, source *Lock)

type GetRevisionParams

type GetRevisionParams struct {
    ID string `db:"id" json:"id"`
}

func (*GetRevisionParams) SetRevision
func (x *GetRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type GetRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type GetRevisionParamsConverter interface {
    // goverter:update target
    SetFromRevision(target *GetRevisionParams, source *Revision)
}

type GetRevisionParamsConverterImpl

type GetRevisionParamsConverterImpl struct{}

func (*GetRevisionParamsConverterImpl) SetFromRevision
func (c *GetRevisionParamsConverterImpl) SetFromRevision(target *GetRevisionParams, source *Revision)

type InsertJobParams

type InsertJobParams struct {
    JobID   string  `db:"job_id" json:"job_id"`
    Status  string  `db:"status" json:"status"`
    Details *string `db:"details" json:"details"`
}

func (*InsertJobParams) SetJob
func (x *InsertJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type InsertJobParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type InsertJobParamsConverter interface {
    // goverter:update target
    SetFromJob(target *InsertJobParams, source *Job)
}

type InsertJobParamsConverterImpl

type InsertJobParamsConverterImpl struct{}

func (*InsertJobParamsConverterImpl) SetFromJob
func (c *InsertJobParamsConverterImpl) SetFromJob(target *InsertJobParams, source *Job)

type InsertLockParams

type InsertLockParams struct {
    ID        string    `db:"id" json:"id"`
    CreatedAt time.Time `db:"created_at" json:"created_at"`
}

func (*InsertLockParams) SetLock
func (x *InsertLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type InsertLockParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type InsertLockParamsConverter interface {
    // goverter:update target
    SetFromLock(target *InsertLockParams, source *Lock)
}

type InsertLockParamsConverterImpl

type InsertLockParamsConverterImpl struct{}

func (*InsertLockParamsConverterImpl) SetFromLock
func (c *InsertLockParamsConverterImpl) SetFromLock(target *InsertLockParams, source *Lock)

type InsertRevisionParams

type InsertRevisionParams struct {
    ID            string        `db:"id" json:"id"`
    Description   string        `db:"description" json:"description"`
    Total         int           `db:"total" json:"total"`
    Count         int           `db:"count" json:"count"`
    Error         *string       `db:"error" json:"error"`
    ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
    ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
    ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*InsertRevisionParams) SetRevision
func (x *InsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type InsertRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type InsertRevisionParamsConverter interface {
    // goverter:update target
    SetFromRevision(target *InsertRevisionParams, source *Revision)
}

type InsertRevisionParamsConverterImpl

type InsertRevisionParamsConverterImpl struct{}

func (*InsertRevisionParamsConverterImpl) SetFromRevision
func (c *InsertRevisionParamsConverterImpl) SetFromRevision(target *InsertRevisionParams, source *Revision)

type Job

type Job struct {
    JobID   string  `db:"job_id" json:"job_id"`
    Status  string  `db:"status" json:"status"`
    Details *string `db:"details" json:"details"`
}

type JobRepository

JobRepository provides methods to interact with the Job entity.

type JobRepository struct {
    Gateway Gateway
}

func (*JobRepository) WaitJob
func (x *JobRepository) WaitJob(ctx context.Context, params *WaitJobParams) (*Job, error)

WaitJob waits for a job to complete and returns the job details.

type ListMigrationsParams

ListMigrationsParams represents the parameters for listing migrations.

type ListMigrationsParams struct{}

type ListRevisionsParams

type ListRevisionsParams struct {
    PageOffset *int32 `db:"page_offset" json:"page_offset"`
    PageLimit  *int32 `db:"page_limit" json:"page_limit"`
}

type Lock

type Lock struct {
    ID        string    `db:"id" json:"id"`
    CreatedAt time.Time `db:"created_at" json:"created_at"`
}

type LockRevisionParams

LockRevisionParams represents the parameters for locking a revision.

type LockRevisionParams struct {
    // Revision contains the parameters for locking a revision.
    Revision *Revision
    // Timeout is the maximum time to wait for the lock.
    Timeout time.Duration
}

type Migration

Migration represents a database migration with its details.

type Migration struct {
    Revision   *Revision
    Statements []string
}

type MigrationRepository

MigrationRepository represents a repository for managing revisions.

type MigrationRepository struct {
    // Gateway represents the database gateway.
    Gateway Gateway
    // FileSystem is the filesystem where the revision files are located.
    FileSystem fs.FS
}

func (*MigrationRepository) ApplyMigration
func (x *MigrationRepository) ApplyMigration(ctx context.Context, params *ApplyMigrationParams) error

ApplyMigration executes a revision.

func (*MigrationRepository) ListMigrations
func (x *MigrationRepository) ListMigrations(ctx context.Context, _ *ListMigrationsParams) (collection []*Migration, _ error)

ListMigrations lists all revisions in the repository.

func (*MigrationRepository) LockRevision
func (x *MigrationRepository) LockRevision(ctx context.Context, params *LockRevisionParams) error

LockRevision locks the revision for exclusive access.

func (*MigrationRepository) UnlockRevision
func (x *MigrationRepository) UnlockRevision(ctx context.Context, params *UnlockRevisionParams) error

UnlockRevision unlocks the revision after exclusive access.

type MigrationState

MigrationState represents the state of a migration operation.

type MigrationState struct {
    Next     *Revision
    Current  *Revision
    Pending  []*Revision
    Executed []*Revision
}

type Querier

type Querier interface {
    // The schema 'sys' is created to hold system-related tables.
    CreateSchemaSys(ctx context.Context) error
    // Creates a table named 'sys.jobs' with the following columns:
    // The table 'sys.jobs' is created to track jobs in the system.
    CreateTableJobs(ctx context.Context) error
    // Creates a table named 'aurora_schema_locks' with the following columns:
    CreateTableLocks(ctx context.Context) error
    // Creates a table named 'aurora_schema_revisions' with the following columns:
    CreateTableRevisions(ctx context.Context) error
    // Deletes a row from the table 'sys.jobs' with option ':one'
    DeleteJob(ctx context.Context, arg *DeleteJobParams) (*Job, error)
    // Deletes a row from the table 'aurora_schema_locks' with option ':one'
    DeleteLock(ctx context.Context, arg *DeleteLockParams) (*Lock, error)
    // Deletes a row from the table 'aurora_schema_revisions' with option ':one'
    DeleteRevision(ctx context.Context, arg *DeleteRevisionParams) (*Revision, error)
    // Deletes a row from the table 'sys.jobs' with option ':exec'
    ExecDeleteJob(ctx context.Context, arg *ExecDeleteJobParams) error
    // Deletes a row from the table 'aurora_schema_locks' with option ':exec'
    ExecDeleteLock(ctx context.Context, arg *ExecDeleteLockParams) error
    // Deletes a row from the table 'aurora_schema_revisions' with option ':exec'
    ExecDeleteRevision(ctx context.Context, arg *ExecDeleteRevisionParams) error
    // Inserts a row into the table 'sys.jobs' with option ':exec'
    ExecInsertJob(ctx context.Context, arg *ExecInsertJobParams) error
    // Inserts a row into the table 'aurora_schema_locks' with option ':exec'
    ExecInsertLock(ctx context.Context, arg *ExecInsertLockParams) error
    // Inserts a row into the table 'aurora_schema_revisions' with option ':exec'
    ExecInsertRevision(ctx context.Context, arg *ExecInsertRevisionParams) error
    // Updates a row in the table 'revision' with option ':exec'
    ExecUpdateRevision(ctx context.Context, arg *ExecUpdateRevisionParams) error
    // Upserts a row into the table 'aurora_schema_revisions' with option ':exec'
    ExecUpsertRevision(ctx context.Context, arg *ExecUpsertRevisionParams) error
    // Retrieves a row from the table 'sys.jobs' with option ':one'
    GetJob(ctx context.Context, arg *GetJobParams) (*Job, error)
    // Retrieves a row from the table 'aurora_schema_locks' with option ':one'
    GetLock(ctx context.Context, arg *GetLockParams) (*Lock, error)
    // Retrieves a row from the table 'aurora_schema_revisions' with option ':one'
    GetRevision(ctx context.Context, arg *GetRevisionParams) (*Revision, error)
    // Inserts a row into the table 'sys.jobs' with option ':one'
    InsertJob(ctx context.Context, arg *InsertJobParams) (*Job, error)
    // Inserts a row into the table 'aurora_schema_locks' with option ':one'
    InsertLock(ctx context.Context, arg *InsertLockParams) (*Lock, error)
    // Inserts a row into the table 'aurora_schema_revisions' with option ':one'
    InsertRevision(ctx context.Context, arg *InsertRevisionParams) (*Revision, error)
    // Retrieves a list of rows from the table 'aurora_schema_revisions' with option ':many'
    ListRevisions(ctx context.Context, arg *ListRevisionsParams) ([]*Revision, error)
    // Updates a row in the table 'revision' with option ':one'
    UpdateRevision(ctx context.Context, arg *UpdateRevisionParams) (*Revision, error)
    // Upserts a row into the table 'aurora_schema_revisions' with option ':one'
    UpsertRevision(ctx context.Context, arg *UpsertRevisionParams) (*Revision, error)
}

type QuerierAction

QuerierAction represents a query action.

type QuerierAction interface {
    // Run runs the action.
    Run(Querier) error
}

func NewQueryPipeline
func NewQueryPipeline(collection ...QuerierFunc) QuerierAction

NewQueryPipeline returns a new QuerierFunc that runs the given steps.

type QuerierFunc

QuerierFunc is a function that runs a query.

type QuerierFunc func(Querier) error

func (QuerierFunc) Run
func (fn QuerierFunc) Run(querier Querier) error

Run runs the query.

type Queries

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

func New
func New(db DBTX) *Queries

func (*Queries) Close
func (x *Queries) Close()

Close closes the connection to the database.

func (*Queries) CreateSchemaSys
func (q *Queries) CreateSchemaSys(ctx context.Context) error

The schema 'sys' is created to hold system-related tables.

func (*Queries) CreateTableJobs
func (q *Queries) CreateTableJobs(ctx context.Context) error

Creates a table named 'sys.jobs' with the following columns: The table 'sys.jobs' is created to track jobs in the system.

func (*Queries) CreateTableLocks
func (q *Queries) CreateTableLocks(ctx context.Context) error

Creates a table named 'aurora_schema_locks' with the following columns:

func (*Queries) CreateTableRevisions
func (q *Queries) CreateTableRevisions(ctx context.Context) error

Creates a table named 'aurora_schema_revisions' with the following columns:

func (*Queries) Database
func (x *Queries) Database() DBTX

Database returns the underlying transaction interface.

func (*Queries) DeleteJob
func (q *Queries) DeleteJob(ctx context.Context, arg *DeleteJobParams) (*Job, error)

Deletes a row from the table 'sys.jobs' with option ':one'

func (*Queries) DeleteLock
func (q *Queries) DeleteLock(ctx context.Context, arg *DeleteLockParams) (*Lock, error)

Deletes a row from the table 'aurora_schema_locks' with option ':one'

func (*Queries) DeleteRevision
func (q *Queries) DeleteRevision(ctx context.Context, arg *DeleteRevisionParams) (*Revision, error)

Deletes a row from the table 'aurora_schema_revisions' with option ':one'

func (*Queries) ExecDeleteJob
func (q *Queries) ExecDeleteJob(ctx context.Context, arg *ExecDeleteJobParams) error

Deletes a row from the table 'sys.jobs' with option ':exec'

func (*Queries) ExecDeleteLock
func (q *Queries) ExecDeleteLock(ctx context.Context, arg *ExecDeleteLockParams) error

Deletes a row from the table 'aurora_schema_locks' with option ':exec'

func (*Queries) ExecDeleteRevision
func (q *Queries) ExecDeleteRevision(ctx context.Context, arg *ExecDeleteRevisionParams) error

Deletes a row from the table 'aurora_schema_revisions' with option ':exec'

func (*Queries) ExecInsertJob
func (q *Queries) ExecInsertJob(ctx context.Context, arg *ExecInsertJobParams) error

Inserts a row into the table 'sys.jobs' with option ':exec'

func (*Queries) ExecInsertLock
func (q *Queries) ExecInsertLock(ctx context.Context, arg *ExecInsertLockParams) error

Inserts a row into the table 'aurora_schema_locks' with option ':exec'

func (*Queries) ExecInsertRevision
func (q *Queries) ExecInsertRevision(ctx context.Context, arg *ExecInsertRevisionParams) error

Inserts a row into the table 'aurora_schema_revisions' with option ':exec'

func (*Queries) ExecUpdateRevision
func (q *Queries) ExecUpdateRevision(ctx context.Context, arg *ExecUpdateRevisionParams) error

Updates a row in the table 'revision' with option ':exec'

func (*Queries) ExecUpsertRevision
func (q *Queries) ExecUpsertRevision(ctx context.Context, arg *ExecUpsertRevisionParams) error

Upserts a row into the table 'aurora_schema_revisions' with option ':exec'

func (*Queries) GetJob
func (q *Queries) GetJob(ctx context.Context, arg *GetJobParams) (*Job, error)

Retrieves a row from the table 'sys.jobs' with option ':one'

func (*Queries) GetLock
func (q *Queries) GetLock(ctx context.Context, arg *GetLockParams) (*Lock, error)

Retrieves a row from the table 'aurora_schema_locks' with option ':one'

func (*Queries) GetRevision
func (q *Queries) GetRevision(ctx context.Context, arg *GetRevisionParams) (*Revision, error)

Retrieves a row from the table 'aurora_schema_revisions' with option ':one'

func (*Queries) InsertJob
func (q *Queries) InsertJob(ctx context.Context, arg *InsertJobParams) (*Job, error)

Inserts a row into the table 'sys.jobs' with option ':one'

func (*Queries) InsertLock
func (q *Queries) InsertLock(ctx context.Context, arg *InsertLockParams) (*Lock, error)

Inserts a row into the table 'aurora_schema_locks' with option ':one'

func (*Queries) InsertRevision
func (q *Queries) InsertRevision(ctx context.Context, arg *InsertRevisionParams) (*Revision, error)

Inserts a row into the table 'aurora_schema_revisions' with option ':one'

func (*Queries) ListRevisions
func (q *Queries) ListRevisions(ctx context.Context, arg *ListRevisionsParams) ([]*Revision, error)

Retrieves a list of rows from the table 'aurora_schema_revisions' with option ':many'

func (*Queries) Ping
func (x *Queries) Ping(ctx context.Context) error

Ping verifies a connection to the database is still alive,

func (*Queries) RunInTx
func (x *Queries) RunInTx(ctx context.Context, action QuerierAction) (err error)

RunInTx runs the given function in a transaction.

func (*Queries) UpdateRevision
func (q *Queries) UpdateRevision(ctx context.Context, arg *UpdateRevisionParams) (*Revision, error)

Updates a row in the table 'revision' with option ':one'

func (*Queries) UpsertRevision
func (q *Queries) UpsertRevision(ctx context.Context, arg *UpsertRevisionParams) (*Revision, error)

Upserts a row into the table 'aurora_schema_revisions' with option ':one'

func (*Queries) WithTx
func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Revision

type Revision struct {
    ID            string        `db:"id" json:"id"`
    Description   string        `db:"description" json:"description"`
    Total         int           `db:"total" json:"total"`
    Count         int           `db:"count" json:"count"`
    Error         *string       `db:"error" json:"error"`
    ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
    ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
    ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*Revision) GetName
func (x *Revision) GetName() string

GetName returns the name of the revision file based on its ID and description.

func (*Revision) SetName
func (x *Revision) SetName(name string)

SetName sets the name of the revision file.

type UnlockRevisionParams

UnlockRevisionParams represents the parameters for unlocking a revision.

type UnlockRevisionParams struct {
    // Revision contains the parameters for unlocking a revision.
    Revision *Revision
}

type UpdateRevisionParams

type UpdateRevisionParams struct {
    UpdateMask    []string      `db:"update_mask" json:"update_mask"`
    Description   string        `db:"description" json:"description"`
    Total         int           `db:"total" json:"total"`
    Count         int           `db:"count" json:"count"`
    Error         *string       `db:"error" json:"error"`
    ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
    ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
    ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
    ID            string        `db:"id" json:"id"`
}

func (*UpdateRevisionParams) SetRevision
func (x *UpdateRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type UpdateRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type UpdateRevisionParamsConverter interface {
    // goverter:update target
    // goverter:ignore UpdateMask
    SetFromRevision(target *UpdateRevisionParams, source *Revision)
}

type UpdateRevisionParamsConverterImpl

type UpdateRevisionParamsConverterImpl struct{}

func (*UpdateRevisionParamsConverterImpl) SetFromRevision
func (c *UpdateRevisionParamsConverterImpl) SetFromRevision(target *UpdateRevisionParams, source *Revision)

type UpsertRevisionParams

type UpsertRevisionParams struct {
    ID            string        `db:"id" json:"id"`
    Description   string        `db:"description" json:"description"`
    Total         int           `db:"total" json:"total"`
    Count         int           `db:"count" json:"count"`
    Error         *string       `db:"error" json:"error"`
    ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
    ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
    ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*UpsertRevisionParams) SetRevision
func (x *UpsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type UpsertRevisionParamsConverter

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type UpsertRevisionParamsConverter interface {
    // goverter:update target
    SetFromRevision(target *UpsertRevisionParams, source *Revision)
}

type UpsertRevisionParamsConverterImpl

type UpsertRevisionParamsConverterImpl struct{}

func (*UpsertRevisionParamsConverterImpl) SetFromRevision
func (c *UpsertRevisionParamsConverterImpl) SetFromRevision(target *UpsertRevisionParams, source *Revision)

type WaitJobParams

WaitJobParams is the parameters for the WaitJob method.

type WaitJobParams struct {
    // Job is the job to wait for.
    JobID string
}

Generated by gomarkdoc

Documentation

Overview

Package ent provides an extension to the ent package for database operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTooManyRows occurs when more rows than expected are returned.
	ErrTooManyRows = pgx.ErrTooManyRows
	// ErrNoRows occurs when rows are expected but none are returned.
	ErrNoRows = pgx.ErrNoRows
)
View Source
var ErrCodeUniqueViolation = pgerrcode.UniqueViolation
View Source
var MigrationLock = uuid.NewMD5(uuid.NameSpaceOID, []byte("aurora_schema_migrations"))

MigrationLock is a UUID used to identify the migration lock in the database.

Functions

func IsErrorCode

func IsErrorCode(err error, code string) bool

IsErrorCode reports whether the error is a PostgreSQL error with the given code.

func IsErrorNotFound

func IsErrorNotFound(err error) bool

IsErrorNotFound reports whether the error is a "not found" error.

func WithURL

func WithURL() string

WithURL returns the database URL.

Types

type ApplyMigrationParams

type ApplyMigrationParams struct {
	// Migration contains the parameters for executing a migration.
	Migration *Migration
}

ApplyMigrationParams represents the parameters for executing a revision.

type Batch

type Batch struct {
	Results pgx.BatchResults
	Total   int
}

Batch represents a batch of results.

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteJobParams

type DeleteJobParams struct {
	JobID string `db:"job_id" json:"job_id"`
}

func (*DeleteJobParams) SetJob

func (x *DeleteJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type DeleteJobParamsConverter

type DeleteJobParamsConverter interface {
	// goverter:update target
	SetFromJob(target *DeleteJobParams, source *Job)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type DeleteJobParamsConverterImpl

type DeleteJobParamsConverterImpl struct{}

func (*DeleteJobParamsConverterImpl) SetFromJob

func (c *DeleteJobParamsConverterImpl) SetFromJob(target *DeleteJobParams, source *Job)

type DeleteLockParams

type DeleteLockParams struct {
	ID string `db:"id" json:"id"`
}

func (*DeleteLockParams) SetLock

func (x *DeleteLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type DeleteLockParamsConverter

type DeleteLockParamsConverter interface {
	// goverter:update target
	SetFromLock(target *DeleteLockParams, source *Lock)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type DeleteLockParamsConverterImpl

type DeleteLockParamsConverterImpl struct{}

func (*DeleteLockParamsConverterImpl) SetFromLock

func (c *DeleteLockParamsConverterImpl) SetFromLock(target *DeleteLockParams, source *Lock)

type DeleteRevisionParams

type DeleteRevisionParams struct {
	ID string `db:"id" json:"id"`
}

func (*DeleteRevisionParams) SetRevision

func (x *DeleteRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type DeleteRevisionParamsConverter

type DeleteRevisionParamsConverter interface {
	// goverter:update target
	SetFromRevision(target *DeleteRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type DeleteRevisionParamsConverterImpl

type DeleteRevisionParamsConverterImpl struct{}

func (*DeleteRevisionParamsConverterImpl) SetFromRevision

func (c *DeleteRevisionParamsConverterImpl) SetFromRevision(target *DeleteRevisionParams, source *Revision)

type Error

type Error = pgconn.PgError

PgError represents an error reported by the PostgreSQL server.

type ExecDeleteJobParams

type ExecDeleteJobParams struct {
	JobID string `db:"job_id" json:"job_id"`
}

func (*ExecDeleteJobParams) SetJob

func (x *ExecDeleteJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type ExecDeleteJobParamsConverter

type ExecDeleteJobParamsConverter interface {
	// goverter:update target
	SetFromJob(target *ExecDeleteJobParams, source *Job)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecDeleteJobParamsConverterImpl

type ExecDeleteJobParamsConverterImpl struct{}

func (*ExecDeleteJobParamsConverterImpl) SetFromJob

func (c *ExecDeleteJobParamsConverterImpl) SetFromJob(target *ExecDeleteJobParams, source *Job)

type ExecDeleteLockParams

type ExecDeleteLockParams struct {
	ID string `db:"id" json:"id"`
}

func (*ExecDeleteLockParams) SetLock

func (x *ExecDeleteLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type ExecDeleteLockParamsConverter

type ExecDeleteLockParamsConverter interface {
	// goverter:update target
	SetFromLock(target *ExecDeleteLockParams, source *Lock)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecDeleteLockParamsConverterImpl

type ExecDeleteLockParamsConverterImpl struct{}

func (*ExecDeleteLockParamsConverterImpl) SetFromLock

func (c *ExecDeleteLockParamsConverterImpl) SetFromLock(target *ExecDeleteLockParams, source *Lock)

type ExecDeleteRevisionParams

type ExecDeleteRevisionParams struct {
	ID string `db:"id" json:"id"`
}

func (*ExecDeleteRevisionParams) SetRevision

func (x *ExecDeleteRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecDeleteRevisionParamsConverter

type ExecDeleteRevisionParamsConverter interface {
	// goverter:update target
	SetFromRevision(target *ExecDeleteRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecDeleteRevisionParamsConverterImpl

type ExecDeleteRevisionParamsConverterImpl struct{}

func (*ExecDeleteRevisionParamsConverterImpl) SetFromRevision

func (c *ExecDeleteRevisionParamsConverterImpl) SetFromRevision(target *ExecDeleteRevisionParams, source *Revision)

type ExecInsertJobParams

type ExecInsertJobParams struct {
	JobID   string  `db:"job_id" json:"job_id"`
	Status  string  `db:"status" json:"status"`
	Details *string `db:"details" json:"details"`
}

func (*ExecInsertJobParams) SetJob

func (x *ExecInsertJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type ExecInsertJobParamsConverter

type ExecInsertJobParamsConverter interface {
	// goverter:update target
	SetFromJob(target *ExecInsertJobParams, source *Job)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecInsertJobParamsConverterImpl

type ExecInsertJobParamsConverterImpl struct{}

func (*ExecInsertJobParamsConverterImpl) SetFromJob

func (c *ExecInsertJobParamsConverterImpl) SetFromJob(target *ExecInsertJobParams, source *Job)

type ExecInsertLockParams

type ExecInsertLockParams struct {
	ID        string    `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
}

func (*ExecInsertLockParams) SetLock

func (x *ExecInsertLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type ExecInsertLockParamsConverter

type ExecInsertLockParamsConverter interface {
	// goverter:update target
	SetFromLock(target *ExecInsertLockParams, source *Lock)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecInsertLockParamsConverterImpl

type ExecInsertLockParamsConverterImpl struct{}

func (*ExecInsertLockParamsConverterImpl) SetFromLock

func (c *ExecInsertLockParamsConverterImpl) SetFromLock(target *ExecInsertLockParams, source *Lock)

type ExecInsertRevisionParams

type ExecInsertRevisionParams struct {
	ID            string        `db:"id" json:"id"`
	Description   string        `db:"description" json:"description"`
	Total         int           `db:"total" json:"total"`
	Count         int           `db:"count" json:"count"`
	Error         *string       `db:"error" json:"error"`
	ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
	ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
	ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*ExecInsertRevisionParams) SetRevision

func (x *ExecInsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecInsertRevisionParamsConverter

type ExecInsertRevisionParamsConverter interface {
	// goverter:update target
	SetFromRevision(target *ExecInsertRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecInsertRevisionParamsConverterImpl

type ExecInsertRevisionParamsConverterImpl struct{}

func (*ExecInsertRevisionParamsConverterImpl) SetFromRevision

func (c *ExecInsertRevisionParamsConverterImpl) SetFromRevision(target *ExecInsertRevisionParams, source *Revision)

type ExecUpdateRevisionParams

type ExecUpdateRevisionParams struct {
	UpdateMask    []string      `db:"update_mask" json:"update_mask"`
	Description   string        `db:"description" json:"description"`
	Total         int           `db:"total" json:"total"`
	Count         int           `db:"count" json:"count"`
	Error         *string       `db:"error" json:"error"`
	ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
	ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
	ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
	ID            string        `db:"id" json:"id"`
}

func (*ExecUpdateRevisionParams) SetRevision

func (x *ExecUpdateRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecUpdateRevisionParamsConverter

type ExecUpdateRevisionParamsConverter interface {
	// goverter:update target
	// goverter:ignore UpdateMask
	SetFromRevision(target *ExecUpdateRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecUpdateRevisionParamsConverterImpl

type ExecUpdateRevisionParamsConverterImpl struct{}

func (*ExecUpdateRevisionParamsConverterImpl) SetFromRevision

func (c *ExecUpdateRevisionParamsConverterImpl) SetFromRevision(target *ExecUpdateRevisionParams, source *Revision)

type ExecUpsertRevisionParams

type ExecUpsertRevisionParams struct {
	ID            string        `db:"id" json:"id"`
	Description   string        `db:"description" json:"description"`
	Total         int           `db:"total" json:"total"`
	Count         int           `db:"count" json:"count"`
	Error         *string       `db:"error" json:"error"`
	ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
	ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
	ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*ExecUpsertRevisionParams) SetRevision

func (x *ExecUpsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type ExecUpsertRevisionParamsConverter

type ExecUpsertRevisionParamsConverter interface {
	// goverter:update target
	SetFromRevision(target *ExecUpsertRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type ExecUpsertRevisionParamsConverterImpl

type ExecUpsertRevisionParamsConverterImpl struct{}

func (*ExecUpsertRevisionParamsConverterImpl) SetFromRevision

func (c *ExecUpsertRevisionParamsConverterImpl) SetFromRevision(target *ExecUpsertRevisionParams, source *Revision)

type FileSystem

type FileSystem interface {
	fs.FS
	fs.GlobFS
	fs.ReadFileFS
}

FileSystem represents a filesystem that supports globbing and reading files.

type Gateway

type Gateway interface {
	// inherit from Querier
	Querier
	// Database returns the underlying transaction interface.
	Database() DBTX
	// RunInTx runs the given function in a transaction.
	RunInTx(context.Context, QuerierAction) error
	// Ping verifies a connection to the database is still alive.
	Ping(context.Context) error
	// Close closes the connection to the database.
	Close()
}

Gateway represents the database gateway.

func Open

func Open(ctx context.Context, uri string, options ...GatewayOption) (_ Gateway, err error)

Open opens a database connection to the given URL.

type GatewayOption

type GatewayOption interface {
	// Apply applies the configuration.
	Apply(*pgxpool.Config) error
}

GatewayOption represents a gateway option.

type GatewayOptionFunc

type GatewayOptionFunc func(*pgxpool.Config) error

GatewayOptionFunc is a function that applies a GatewayOption.

func (GatewayOptionFunc) Apply

func (fn GatewayOptionFunc) Apply(cfg *pgxpool.Config) error

Apply applies the GatewayOptionFunc to the Gateway.

type GetJobParams

type GetJobParams struct {
	JobID string `db:"job_id" json:"job_id"`
}

func (*GetJobParams) SetJob

func (x *GetJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type GetJobParamsConverter

type GetJobParamsConverter interface {
	// goverter:update target
	SetFromJob(target *GetJobParams, source *Job)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type GetJobParamsConverterImpl

type GetJobParamsConverterImpl struct{}

func (*GetJobParamsConverterImpl) SetFromJob

func (c *GetJobParamsConverterImpl) SetFromJob(target *GetJobParams, source *Job)

type GetLockParams

type GetLockParams struct {
	ID string `db:"id" json:"id"`
}

func (*GetLockParams) SetLock

func (x *GetLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type GetLockParamsConverter

type GetLockParamsConverter interface {
	// goverter:update target
	SetFromLock(target *GetLockParams, source *Lock)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type GetLockParamsConverterImpl

type GetLockParamsConverterImpl struct{}

func (*GetLockParamsConverterImpl) SetFromLock

func (c *GetLockParamsConverterImpl) SetFromLock(target *GetLockParams, source *Lock)

type GetRevisionParams

type GetRevisionParams struct {
	ID string `db:"id" json:"id"`
}

func (*GetRevisionParams) SetRevision

func (x *GetRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type GetRevisionParamsConverter

type GetRevisionParamsConverter interface {
	// goverter:update target
	SetFromRevision(target *GetRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type GetRevisionParamsConverterImpl

type GetRevisionParamsConverterImpl struct{}

func (*GetRevisionParamsConverterImpl) SetFromRevision

func (c *GetRevisionParamsConverterImpl) SetFromRevision(target *GetRevisionParams, source *Revision)

type InsertJobParams

type InsertJobParams struct {
	JobID   string  `db:"job_id" json:"job_id"`
	Status  string  `db:"status" json:"status"`
	Details *string `db:"details" json:"details"`
}

func (*InsertJobParams) SetJob

func (x *InsertJobParams) SetJob(entity *Job)

SetJob sets the params from the entity.

type InsertJobParamsConverter

type InsertJobParamsConverter interface {
	// goverter:update target
	SetFromJob(target *InsertJobParams, source *Job)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type InsertJobParamsConverterImpl

type InsertJobParamsConverterImpl struct{}

func (*InsertJobParamsConverterImpl) SetFromJob

func (c *InsertJobParamsConverterImpl) SetFromJob(target *InsertJobParams, source *Job)

type InsertLockParams

type InsertLockParams struct {
	ID        string    `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
}

func (*InsertLockParams) SetLock

func (x *InsertLockParams) SetLock(entity *Lock)

SetLock sets the params from the entity.

type InsertLockParamsConverter

type InsertLockParamsConverter interface {
	// goverter:update target
	SetFromLock(target *InsertLockParams, source *Lock)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type InsertLockParamsConverterImpl

type InsertLockParamsConverterImpl struct{}

func (*InsertLockParamsConverterImpl) SetFromLock

func (c *InsertLockParamsConverterImpl) SetFromLock(target *InsertLockParams, source *Lock)

type InsertRevisionParams

type InsertRevisionParams struct {
	ID            string        `db:"id" json:"id"`
	Description   string        `db:"description" json:"description"`
	Total         int           `db:"total" json:"total"`
	Count         int           `db:"count" json:"count"`
	Error         *string       `db:"error" json:"error"`
	ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
	ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
	ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*InsertRevisionParams) SetRevision

func (x *InsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type InsertRevisionParamsConverter

type InsertRevisionParamsConverter interface {
	// goverter:update target
	SetFromRevision(target *InsertRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type InsertRevisionParamsConverterImpl

type InsertRevisionParamsConverterImpl struct{}

func (*InsertRevisionParamsConverterImpl) SetFromRevision

func (c *InsertRevisionParamsConverterImpl) SetFromRevision(target *InsertRevisionParams, source *Revision)

type Job

type Job struct {
	JobID   string  `db:"job_id" json:"job_id"`
	Status  string  `db:"status" json:"status"`
	Details *string `db:"details" json:"details"`
}

type JobRepository

type JobRepository struct {
	Gateway Gateway
}

JobRepository provides methods to interact with the Job entity.

func (*JobRepository) WaitJob

func (x *JobRepository) WaitJob(ctx context.Context, params *WaitJobParams) (*Job, error)

WaitJob waits for a job to complete and returns the job details.

type ListMigrationsParams

type ListMigrationsParams struct{}

ListMigrationsParams represents the parameters for listing migrations.

type ListRevisionsParams

type ListRevisionsParams struct {
	PageOffset *int32 `db:"page_offset" json:"page_offset"`
	PageLimit  *int32 `db:"page_limit" json:"page_limit"`
}

type Lock

type Lock struct {
	ID        string    `db:"id" json:"id"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
}

type LockMigrationParams

type LockMigrationParams struct {
	// Timeout is the maximum time to wait for the lock.
	Timeout time.Duration
}

LockMigrationParams represents the parameters for locking a revision.

type Migration

type Migration struct {
	Revision   *Revision
	Statements []string
}

Migration represents a database migration with its details.

type MigrationRepository

type MigrationRepository struct {
	// Gateway represents the database gateway.
	Gateway Gateway
	// FileSystem is the filesystem where the revision files are located.
	FileSystem fs.FS
}

MigrationRepository represents a repository for managing revisions.

func (*MigrationRepository) ApplyMigration

func (x *MigrationRepository) ApplyMigration(ctx context.Context, params *ApplyMigrationParams) error

ApplyMigration executes a revision.

func (*MigrationRepository) ListMigrations

func (x *MigrationRepository) ListMigrations(ctx context.Context, _ *ListMigrationsParams) (collection []*Migration, _ error)

ListMigrations lists all revisions in the repository.

func (*MigrationRepository) LockMigration

func (x *MigrationRepository) LockMigration(ctx context.Context, params *LockMigrationParams) error

LockMigration locks a revision for exclusive access.

func (*MigrationRepository) UnlockMigration

func (x *MigrationRepository) UnlockMigration(ctx context.Context) error

UnlockMigration unlocks the revision after exclusive access.

type MigrationState

type MigrationState struct {
	Next     *Revision
	Current  *Revision
	Pending  []*Revision
	Executed []*Revision
}

MigrationState represents the state of a migration operation.

type Querier

type Querier interface {
	// The schema 'sys' is created to hold system-related tables.
	CreateSchemaSys(ctx context.Context) error
	// Creates a table named 'sys.jobs' with the following columns:
	// The table 'sys.jobs' is created to track jobs in the system.
	CreateTableJobs(ctx context.Context) error
	// Creates a table named 'aurora_schema_locks' with the following columns:
	CreateTableLocks(ctx context.Context) error
	// Creates a table named 'aurora_schema_revisions' with the following columns:
	CreateTableRevisions(ctx context.Context) error
	// Deletes a row from the table 'sys.jobs' with option ':one'
	DeleteJob(ctx context.Context, arg *DeleteJobParams) (*Job, error)
	// Deletes a row from the table 'aurora_schema_locks' with option ':one'
	DeleteLock(ctx context.Context, arg *DeleteLockParams) (*Lock, error)
	// Deletes a row from the table 'aurora_schema_revisions' with option ':one'
	DeleteRevision(ctx context.Context, arg *DeleteRevisionParams) (*Revision, error)
	// Deletes a row from the table 'sys.jobs' with option ':exec'
	ExecDeleteJob(ctx context.Context, arg *ExecDeleteJobParams) error
	// Deletes a row from the table 'aurora_schema_locks' with option ':exec'
	ExecDeleteLock(ctx context.Context, arg *ExecDeleteLockParams) error
	// Deletes a row from the table 'aurora_schema_revisions' with option ':exec'
	ExecDeleteRevision(ctx context.Context, arg *ExecDeleteRevisionParams) error
	// Inserts a row into the table 'sys.jobs' with option ':exec'
	ExecInsertJob(ctx context.Context, arg *ExecInsertJobParams) error
	// Inserts a row into the table 'aurora_schema_locks' with option ':exec'
	ExecInsertLock(ctx context.Context, arg *ExecInsertLockParams) error
	// Inserts a row into the table 'aurora_schema_revisions' with option ':exec'
	ExecInsertRevision(ctx context.Context, arg *ExecInsertRevisionParams) error
	// Updates a row in the table 'revision' with option ':exec'
	ExecUpdateRevision(ctx context.Context, arg *ExecUpdateRevisionParams) error
	// Upserts a row into the table 'aurora_schema_revisions' with option ':exec'
	ExecUpsertRevision(ctx context.Context, arg *ExecUpsertRevisionParams) error
	// Retrieves a row from the table 'sys.jobs' with option ':one'
	GetJob(ctx context.Context, arg *GetJobParams) (*Job, error)
	// Retrieves a row from the table 'aurora_schema_locks' with option ':one'
	GetLock(ctx context.Context, arg *GetLockParams) (*Lock, error)
	// Retrieves a row from the table 'aurora_schema_revisions' with option ':one'
	GetRevision(ctx context.Context, arg *GetRevisionParams) (*Revision, error)
	// Inserts a row into the table 'sys.jobs' with option ':one'
	InsertJob(ctx context.Context, arg *InsertJobParams) (*Job, error)
	// Inserts a row into the table 'aurora_schema_locks' with option ':one'
	InsertLock(ctx context.Context, arg *InsertLockParams) (*Lock, error)
	// Inserts a row into the table 'aurora_schema_revisions' with option ':one'
	InsertRevision(ctx context.Context, arg *InsertRevisionParams) (*Revision, error)
	// Retrieves a list of rows from the table 'aurora_schema_revisions' with option ':many'
	ListRevisions(ctx context.Context, arg *ListRevisionsParams) ([]*Revision, error)
	// Updates a row in the table 'revision' with option ':one'
	UpdateRevision(ctx context.Context, arg *UpdateRevisionParams) (*Revision, error)
	// Upserts a row into the table 'aurora_schema_revisions' with option ':one'
	UpsertRevision(ctx context.Context, arg *UpsertRevisionParams) (*Revision, error)
}

type QuerierAction

type QuerierAction interface {
	// Run runs the action.
	Run(Querier) error
}

QuerierAction represents a query action.

func NewQueryPipeline

func NewQueryPipeline(collection ...QuerierFunc) QuerierAction

NewQueryPipeline returns a new QuerierFunc that runs the given steps.

type QuerierFunc

type QuerierFunc func(Querier) error

QuerierFunc is a function that runs a query.

func (QuerierFunc) Run

func (fn QuerierFunc) Run(querier Querier) error

Run runs the query.

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) Close

func (x *Queries) Close()

Close closes the connection to the database.

func (*Queries) CreateSchemaSys

func (q *Queries) CreateSchemaSys(ctx context.Context) error

The schema 'sys' is created to hold system-related tables.

func (*Queries) CreateTableJobs

func (q *Queries) CreateTableJobs(ctx context.Context) error

Creates a table named 'sys.jobs' with the following columns: The table 'sys.jobs' is created to track jobs in the system.

func (*Queries) CreateTableLocks

func (q *Queries) CreateTableLocks(ctx context.Context) error

Creates a table named 'aurora_schema_locks' with the following columns:

func (*Queries) CreateTableRevisions

func (q *Queries) CreateTableRevisions(ctx context.Context) error

Creates a table named 'aurora_schema_revisions' with the following columns:

func (*Queries) Database

func (x *Queries) Database() DBTX

Database returns the underlying transaction interface.

func (*Queries) DeleteJob

func (q *Queries) DeleteJob(ctx context.Context, arg *DeleteJobParams) (*Job, error)

Deletes a row from the table 'sys.jobs' with option ':one'

func (*Queries) DeleteLock

func (q *Queries) DeleteLock(ctx context.Context, arg *DeleteLockParams) (*Lock, error)

Deletes a row from the table 'aurora_schema_locks' with option ':one'

func (*Queries) DeleteRevision

func (q *Queries) DeleteRevision(ctx context.Context, arg *DeleteRevisionParams) (*Revision, error)

Deletes a row from the table 'aurora_schema_revisions' with option ':one'

func (*Queries) ExecDeleteJob

func (q *Queries) ExecDeleteJob(ctx context.Context, arg *ExecDeleteJobParams) error

Deletes a row from the table 'sys.jobs' with option ':exec'

func (*Queries) ExecDeleteLock

func (q *Queries) ExecDeleteLock(ctx context.Context, arg *ExecDeleteLockParams) error

Deletes a row from the table 'aurora_schema_locks' with option ':exec'

func (*Queries) ExecDeleteRevision

func (q *Queries) ExecDeleteRevision(ctx context.Context, arg *ExecDeleteRevisionParams) error

Deletes a row from the table 'aurora_schema_revisions' with option ':exec'

func (*Queries) ExecInsertJob

func (q *Queries) ExecInsertJob(ctx context.Context, arg *ExecInsertJobParams) error

Inserts a row into the table 'sys.jobs' with option ':exec'

func (*Queries) ExecInsertLock

func (q *Queries) ExecInsertLock(ctx context.Context, arg *ExecInsertLockParams) error

Inserts a row into the table 'aurora_schema_locks' with option ':exec'

func (*Queries) ExecInsertRevision

func (q *Queries) ExecInsertRevision(ctx context.Context, arg *ExecInsertRevisionParams) error

Inserts a row into the table 'aurora_schema_revisions' with option ':exec'

func (*Queries) ExecUpdateRevision

func (q *Queries) ExecUpdateRevision(ctx context.Context, arg *ExecUpdateRevisionParams) error

Updates a row in the table 'revision' with option ':exec'

func (*Queries) ExecUpsertRevision

func (q *Queries) ExecUpsertRevision(ctx context.Context, arg *ExecUpsertRevisionParams) error

Upserts a row into the table 'aurora_schema_revisions' with option ':exec'

func (*Queries) GetJob

func (q *Queries) GetJob(ctx context.Context, arg *GetJobParams) (*Job, error)

Retrieves a row from the table 'sys.jobs' with option ':one'

func (*Queries) GetLock

func (q *Queries) GetLock(ctx context.Context, arg *GetLockParams) (*Lock, error)

Retrieves a row from the table 'aurora_schema_locks' with option ':one'

func (*Queries) GetRevision

func (q *Queries) GetRevision(ctx context.Context, arg *GetRevisionParams) (*Revision, error)

Retrieves a row from the table 'aurora_schema_revisions' with option ':one'

func (*Queries) InsertJob

func (q *Queries) InsertJob(ctx context.Context, arg *InsertJobParams) (*Job, error)

Inserts a row into the table 'sys.jobs' with option ':one'

func (*Queries) InsertLock

func (q *Queries) InsertLock(ctx context.Context, arg *InsertLockParams) (*Lock, error)

Inserts a row into the table 'aurora_schema_locks' with option ':one'

func (*Queries) InsertRevision

func (q *Queries) InsertRevision(ctx context.Context, arg *InsertRevisionParams) (*Revision, error)

Inserts a row into the table 'aurora_schema_revisions' with option ':one'

func (*Queries) ListRevisions

func (q *Queries) ListRevisions(ctx context.Context, arg *ListRevisionsParams) ([]*Revision, error)

Retrieves a list of rows from the table 'aurora_schema_revisions' with option ':many'

func (*Queries) Ping

func (x *Queries) Ping(ctx context.Context) error

Ping verifies a connection to the database is still alive,

func (*Queries) RunInTx

func (x *Queries) RunInTx(ctx context.Context, action QuerierAction) (err error)

RunInTx runs the given function in a transaction.

func (*Queries) UpdateRevision

func (q *Queries) UpdateRevision(ctx context.Context, arg *UpdateRevisionParams) (*Revision, error)

Updates a row in the table 'revision' with option ':one'

func (*Queries) UpsertRevision

func (q *Queries) UpsertRevision(ctx context.Context, arg *UpsertRevisionParams) (*Revision, error)

Upserts a row into the table 'aurora_schema_revisions' with option ':one'

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Revision

type Revision struct {
	ID            string        `db:"id" json:"id"`
	Description   string        `db:"description" json:"description"`
	Total         int           `db:"total" json:"total"`
	Count         int           `db:"count" json:"count"`
	Error         *string       `db:"error" json:"error"`
	ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
	ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
	ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*Revision) GetName

func (x *Revision) GetName() string

GetName returns the name of the revision file based on its ID and description.

func (*Revision) SetName

func (x *Revision) SetName(name string)

SetName sets the name of the revision file.

type UpdateRevisionParams

type UpdateRevisionParams struct {
	UpdateMask    []string      `db:"update_mask" json:"update_mask"`
	Description   string        `db:"description" json:"description"`
	Total         int           `db:"total" json:"total"`
	Count         int           `db:"count" json:"count"`
	Error         *string       `db:"error" json:"error"`
	ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
	ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
	ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
	ID            string        `db:"id" json:"id"`
}

func (*UpdateRevisionParams) SetRevision

func (x *UpdateRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type UpdateRevisionParamsConverter

type UpdateRevisionParamsConverter interface {
	// goverter:update target
	// goverter:ignore UpdateMask
	SetFromRevision(target *UpdateRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type UpdateRevisionParamsConverterImpl

type UpdateRevisionParamsConverterImpl struct{}

func (*UpdateRevisionParamsConverterImpl) SetFromRevision

func (c *UpdateRevisionParamsConverterImpl) SetFromRevision(target *UpdateRevisionParams, source *Revision)

type UpsertRevisionParams

type UpsertRevisionParams struct {
	ID            string        `db:"id" json:"id"`
	Description   string        `db:"description" json:"description"`
	Total         int           `db:"total" json:"total"`
	Count         int           `db:"count" json:"count"`
	Error         *string       `db:"error" json:"error"`
	ErrorStmt     *string       `db:"error_stmt" json:"error_stmt"`
	ExecutedAt    time.Time     `db:"executed_at" json:"executed_at"`
	ExecutionTime time.Duration `db:"execution_time" json:"execution_time"`
}

func (*UpsertRevisionParams) SetRevision

func (x *UpsertRevisionParams) SetRevision(entity *Revision)

SetRevision sets the params from the entity.

type UpsertRevisionParamsConverter

type UpsertRevisionParamsConverter interface {
	// goverter:update target
	SetFromRevision(target *UpsertRevisionParams, source *Revision)
}

goverter:converter goverter:skipCopySameType yes goverter:output:file models_conv_gen.go goverter:output:package github.com/aws-contrib/aws-aurora/internal/database/ent

type UpsertRevisionParamsConverterImpl

type UpsertRevisionParamsConverterImpl struct{}

func (*UpsertRevisionParamsConverterImpl) SetFromRevision

func (c *UpsertRevisionParamsConverterImpl) SetFromRevision(target *UpsertRevisionParams, source *Revision)

type WaitJobParams

type WaitJobParams struct {
	// Job is the job to wait for.
	JobID string
}

WaitJobParams is the parameters for the WaitJob method.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
Package template provides functions to colorize strings for reporting purposes.
Package template provides functions to colorize strings for reporting purposes.

Jump to

Keyboard shortcuts

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