entities

package
v0.0.0-pre.4 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is the error returned, if the entity is not found in the DB.
	ErrNotFound = errors.New("Not found")

	// ErrConflict is the error returned, if the adding or updating an entity
	// causes a conflict with an existing entity.
	ErrConflict = errors.New("Conflict")
)
View Source
var PreparedStmts = map[int]*sql.Stmt{}

PreparedStmts is a placeholder for transitioning to package-scoped transaction functions.

Functions

func BatchExists

func BatchExists(ctx context.Context, db dbtx, name string) (_ bool, _err error)

BatchExists checks if a batch with the given key exists. generator: batch Exists

func CreateBatch

func CreateBatch(ctx context.Context, db dbtx, object migration.Batch) (_ int64, _err error)

CreateBatch adds a new batch to the database. generator: batch Create

func CreateBatchMigrationWindows

func CreateBatchMigrationWindows(ctx context.Context, db tx, objects []BatchMigrationWindow) (_err error)

CreateBatchMigrationWindows adds a new batch_migration_window to the database. generator: batch_migration_window Create

func CreateInstance

func CreateInstance(ctx context.Context, db dbtx, object migration.Instance) (_ int64, _err error)

CreateInstance adds a new instance to the database. generator: instance Create

func CreateInstanceBatches

func CreateInstanceBatches(ctx context.Context, db tx, objects []InstanceBatch) (_err error)

CreateInstanceBatches adds a new instance_batch to the database. generator: instance_batch Create

func CreateMigrationWindow

func CreateMigrationWindow(ctx context.Context, db dbtx, object migration.MigrationWindow) (_ int64, _err error)

CreateMigrationWindow adds a new migration_window to the database. generator: migration_window Create

func CreateNetwork

func CreateNetwork(ctx context.Context, db dbtx, object migration.Network) (_ int64, _err error)

CreateNetwork adds a new network to the database. generator: network Create

func CreateQueueEntry

func CreateQueueEntry(ctx context.Context, db dbtx, object migration.QueueEntry) (_ int64, _err error)

CreateQueueEntry adds a new queue_entry to the database. generator: queue_entry Create

func CreateSource

func CreateSource(ctx context.Context, db dbtx, object migration.Source) (_ int64, _err error)

CreateSource adds a new source to the database. generator: source Create

func CreateTarget

func CreateTarget(ctx context.Context, db dbtx, object migration.Target) (_ int64, _err error)

CreateTarget adds a new target to the database. generator: target Create

func DeleteBatch

func DeleteBatch(ctx context.Context, db dbtx, name string) (_err error)

DeleteBatch deletes the batch matching the given key parameters. generator: batch DeleteOne-by-Name

func DeleteBatchMigrationWindows

func DeleteBatchMigrationWindows(ctx context.Context, db tx, batchID int) (_err error)

DeleteBatchMigrationWindows deletes the batch_migration_window matching the given key parameters. generator: batch_migration_window DeleteMany

func DeleteInstance

func DeleteInstance(ctx context.Context, db dbtx, uuid uuid.UUID) (_err error)

DeleteInstance deletes the instance matching the given key parameters. generator: instance DeleteOne-by-UUID

func DeleteInstanceBatch

func DeleteInstanceBatch(ctx context.Context, db tx, instanceID int, batchID int) (_err error)

DeleteInstanceBatch deletes the instance_batch matching the given key parameters.

func DeleteInstanceBatches

func DeleteInstanceBatches(ctx context.Context, db tx, instanceID int) (_err error)

DeleteInstanceBatches deletes the instance_batch matching the given key parameters. generator: instance_batch DeleteMany

func DeleteMigrationWindow

func DeleteMigrationWindow(ctx context.Context, db dbtx, start time.Time, end time.Time, lockout time.Time) (_err error)

DeleteMigrationWindow deletes the migration_window matching the given key parameters. generator: migration_window DeleteOne-by-Start-and-End-and-Lockout

func DeleteNetwork

func DeleteNetwork(ctx context.Context, db dbtx, identifier string, source string) (_err error)

DeleteNetwork deletes the network matching the given key parameters. generator: network DeleteOne-by-Identifier-and-Source

func DeleteQueueEntries

func DeleteQueueEntries(ctx context.Context, db dbtx, batchName string) (_err error)

DeleteQueueEntries deletes the queue_entry matching the given key parameters. generator: queue_entry DeleteMany-by-BatchName

func DeleteQueueEntry

func DeleteQueueEntry(ctx context.Context, db dbtx, instanceUUID uuid.UUID) (_err error)

DeleteQueueEntry deletes the queue_entry matching the given key parameters. generator: queue_entry DeleteOne-by-InstanceUUID

func DeleteSource

func DeleteSource(ctx context.Context, db dbtx, name string) (_err error)

DeleteSource deletes the source matching the given key parameters. generator: source DeleteOne-by-Name

func DeleteTarget

func DeleteTarget(ctx context.Context, db dbtx, name string) (_err error)

DeleteTarget deletes the target matching the given key parameters. generator: target DeleteOne-by-Name

func GetAssignedInstances

func GetAssignedInstances(ctx context.Context, tx dbtx) (migration.Instances, error)

func GetBatch

func GetBatch(ctx context.Context, db dbtx, name string) (_ *migration.Batch, _err error)

GetBatch returns the batch with the given key. generator: batch GetOne

func GetBatchID

func GetBatchID(ctx context.Context, db tx, name string) (_ int64, _err error)

GetBatchID return the ID of the batch with the given key. generator: batch ID

func GetBatchInstances

func GetBatchInstances(ctx context.Context, db tx, batchID int) (_ []migration.Instance, _err error)

GetBatchInstances returns all available Instances for the Batch. generator: instance_batch GetMany

func GetBatchNames

func GetBatchNames(ctx context.Context, db dbtx, filters ...BatchFilter) (_ []string, _err error)

GetBatchNames returns the identifying field of batch. generator: batch GetNames

func GetBatches

func GetBatches(ctx context.Context, db dbtx, filters ...BatchFilter) (_ []migration.Batch, _err error)

GetBatches returns all available batches. generator: batch GetMany

func GetBatchesByInstance

func GetBatchesByInstance(ctx context.Context, tx dbtx, instanceUUID *uuid.UUID) (migration.Batches, error)

func GetInstance

func GetInstance(ctx context.Context, db dbtx, uuid uuid.UUID) (_ *migration.Instance, _err error)

GetInstance returns the instance with the given key. generator: instance GetOne

func GetInstanceBatches

func GetInstanceBatches(ctx context.Context, db tx, instanceID int) (_ []migration.Batch, _err error)

GetInstanceBatches returns all available Batches for the Instance. generator: instance_batch GetMany

func GetInstanceID

func GetInstanceID(ctx context.Context, db tx, uuid uuid.UUID) (_ int64, _err error)

GetInstanceID return the ID of the instance with the given key. generator: instance ID

func GetInstanceNames

func GetInstanceNames(ctx context.Context, db dbtx, filters ...InstanceFilter) (_ []uuid.UUID, _err error)

GetInstanceNames returns the identifying field of instance. generator: instance GetNames

func GetInstances

func GetInstances(ctx context.Context, db dbtx, filters ...InstanceFilter) (_ []migration.Instance, _err error)

GetInstances returns all available instances. generator: instance GetMany

func GetInstancesByBatch

func GetInstancesByBatch(ctx context.Context, tx dbtx, batchName *string) (migration.Instances, error)

func GetMigrationWindow

func GetMigrationWindow(ctx context.Context, db dbtx, start time.Time, end time.Time, lockout time.Time) (_ *migration.MigrationWindow, _err error)

GetMigrationWindow returns the migration_window with the given key. generator: migration_window GetOne

func GetMigrationWindowID

func GetMigrationWindowID(ctx context.Context, db tx, start time.Time, end time.Time, lockout time.Time) (_ int64, _err error)

GetMigrationWindowID return the ID of the migration_window with the given key. generator: migration_window ID

func GetMigrationWindows

func GetMigrationWindows(ctx context.Context, db dbtx, filters ...MigrationWindowFilter) (_ []migration.MigrationWindow, _err error)

GetMigrationWindows returns all available migration_windows. generator: migration_window GetMany

func GetMigrationWindowsByBatch

func GetMigrationWindowsByBatch(ctx context.Context, tx dbtx, batchName *string) ([]migration.MigrationWindow, error)

GetMigrationWindowsByBatch returns all MigrationWindows for the given batch name. If the batch name is nil, it will return all MigrationWindows for which there is no assigned batch.

func GetNetwork

func GetNetwork(ctx context.Context, db dbtx, identifier string, source string) (_ *migration.Network, _err error)

GetNetwork returns the network with the given key. generator: network GetOne

func GetNetworkID

func GetNetworkID(ctx context.Context, db tx, identifier string, source string) (_ int64, _err error)

GetNetworkID return the ID of the network with the given key. generator: network ID

func GetNetworks

func GetNetworks(ctx context.Context, db dbtx, filters ...NetworkFilter) (_ []migration.Network, _err error)

GetNetworks returns all available networks. generator: network GetMany

func GetQueueEntries

func GetQueueEntries(ctx context.Context, db dbtx, filters ...QueueEntryFilter) (_ []migration.QueueEntry, _err error)

GetQueueEntries returns all available queue_entries. generator: queue_entry GetMany

func GetQueueEntry

func GetQueueEntry(ctx context.Context, db dbtx, instanceUUID uuid.UUID) (_ *migration.QueueEntry, _err error)

GetQueueEntry returns the queue_entry with the given key. generator: queue_entry GetOne

func GetQueueEntryID

func GetQueueEntryID(ctx context.Context, db tx, instanceUUID uuid.UUID) (_ int64, _err error)

GetQueueEntryID return the ID of the queue_entry with the given key. generator: queue_entry ID

func GetSource

func GetSource(ctx context.Context, db dbtx, name string) (_ *migration.Source, _err error)

GetSource returns the source with the given key. generator: source GetOne

func GetSourceID

func GetSourceID(ctx context.Context, db tx, name string) (_ int64, _err error)

GetSourceID return the ID of the source with the given key. generator: source ID

func GetSourceNames

func GetSourceNames(ctx context.Context, db dbtx, filters ...SourceFilter) (_ []string, _err error)

GetSourceNames returns the identifying field of source. generator: source GetNames

func GetSources

func GetSources(ctx context.Context, db dbtx, filters ...SourceFilter) (_ []migration.Source, _err error)

GetSources returns all available sources. generator: source GetMany

func GetTarget

func GetTarget(ctx context.Context, db dbtx, name string) (_ *migration.Target, _err error)

GetTarget returns the target with the given key. generator: target GetOne

func GetTargetID

func GetTargetID(ctx context.Context, db tx, name string) (_ int64, _err error)

GetTargetID return the ID of the target with the given key. generator: target ID

func GetTargetNames

func GetTargetNames(ctx context.Context, db dbtx, filters ...TargetFilter) (_ []string, _err error)

GetTargetNames returns the identifying field of target. generator: target GetNames

func GetTargets

func GetTargets(ctx context.Context, db dbtx, filters ...TargetFilter) (_ []migration.Target, _err error)

GetTargets returns all available targets. generator: target GetMany

func NetworkExists

func NetworkExists(ctx context.Context, db dbtx, identifier string, source string) (_ bool, _err error)

NetworkExists checks if a network with the given key exists. generator: network Exists

func PrepareStmts

func PrepareStmts(db preparer, skipErrors bool) (map[int]*sql.Stmt, error)

PrepareStmts prepares all registered statements and returns an index from statement code to prepared statement object.

func RegisterStmt

func RegisterStmt(sqlStmt string) int

RegisterStmt register a SQL statement.

Registered statements will be prepared upfront and reused, to speed up execution.

Return a unique registration code.

func RenameBatch

func RenameBatch(ctx context.Context, db dbtx, name string, to string) (_err error)

RenameBatch renames the batch matching the given key parameters. generator: batch Rename

func RenameSource

func RenameSource(ctx context.Context, db dbtx, name string, to string) (_err error)

RenameSource renames the source matching the given key parameters. generator: source Rename

func RenameTarget

func RenameTarget(ctx context.Context, db dbtx, name string, to string) (_err error)

RenameTarget renames the target matching the given key parameters. generator: target Rename

func SourceExists

func SourceExists(ctx context.Context, db dbtx, name string) (_ bool, _err error)

SourceExists checks if a source with the given key exists. generator: source Exists

func Stmt

func Stmt(db dbtx, code int) (*sql.Stmt, error)

Stmt prepares the in-memory prepared statement for the transaction.

func StmtString

func StmtString(code int) (string, error)

StmtString returns the in-memory query string with the given code.

func TargetExists

func TargetExists(ctx context.Context, db dbtx, name string) (_ bool, _err error)

TargetExists checks if a target with the given key exists. generator: target Exists

func UpdateBatch

func UpdateBatch(ctx context.Context, db tx, name string, object migration.Batch) (_err error)

UpdateBatch updates the batch matching the given key parameters. generator: batch Update

func UpdateInstance

func UpdateInstance(ctx context.Context, db tx, uuid uuid.UUID, object migration.Instance) (_err error)

UpdateInstance updates the instance matching the given key parameters. generator: instance Update

func UpdateMigrationWindow

func UpdateMigrationWindow(ctx context.Context, db tx, start time.Time, end time.Time, lockout time.Time, object migration.MigrationWindow) (_err error)

UpdateMigrationWindow updates the migration_window matching the given key parameters. generator: migration_window Update

func UpdateNetwork

func UpdateNetwork(ctx context.Context, db tx, identifier string, source string, object migration.Network) (_err error)

UpdateNetwork updates the network matching the given key parameters. generator: network Update

func UpdateQueueEntry

func UpdateQueueEntry(ctx context.Context, db tx, instanceUUID uuid.UUID, object migration.QueueEntry) (_err error)

UpdateQueueEntry updates the queue_entry matching the given key parameters. generator: queue_entry Update

func UpdateSource

func UpdateSource(ctx context.Context, db tx, name string, object migration.Source) (_err error)

UpdateSource updates the source matching the given key parameters. generator: source Update

func UpdateTarget

func UpdateTarget(ctx context.Context, db tx, name string, object migration.Target) (_err error)

UpdateTarget updates the target matching the given key parameters. generator: target Update

Types

type BatchFilter

type BatchFilter struct {
	ID     *int64
	Name   *string
	Status *api.BatchStatusType
}

type BatchMigrationWindow

type BatchMigrationWindow struct {
	BatchID           int64 `db:"primary=yes"`
	MigrationWindowID int64
}

type BatchMigrationWindowFilter

type BatchMigrationWindowFilter struct {
	BatchID           *int64
	MigrationWindowID *int64
}

type InstanceBatch

type InstanceBatch struct {
	BatchID    int64 `db:"primary=yes"`
	InstanceID int64 `db:"primary=yes"`
}

type InstanceBatchFilter

type InstanceBatchFilter struct {
	BatchID    *int64
	InstanceID *int64
}

type InstanceFilter

type InstanceFilter struct {
	ID     *int64
	UUID   *uuid.UUID
	Source *string
}

type Marshaler

type Marshaler interface {
	MarshalDB() (string, error)
}

Marshaler is the interface that wraps the MarshalDB method, which converts the underlying type into a string representation suitable for persistence in the database.

type MigrationWindowFilter

type MigrationWindowFilter struct {
	ID      *int64
	Start   *time.Time
	End     *time.Time
	Lockout *time.Time
}

type NetworkFilter

type NetworkFilter struct {
	Identifier *string
	Source     *string
}

type QueueEntryFilter

type QueueEntryFilter struct {
	InstanceUUID    *uuid.UUID
	BatchName       *string
	MigrationStatus *api.MigrationStatusType
	NeedsDiskImport *bool
}

type SourceFilter

type SourceFilter struct {
	SourceType *api.SourceType
	Name       *string
}

type TargetFilter

type TargetFilter struct {
	Name *string
}

type Unmarshaler

type Unmarshaler interface {
	UnmarshalDB(string) error
}

Unmarshaler is the interface that wraps the UnmarshalDB method, which converts a string representation retrieved from the database into the underlying type.

Jump to

Keyboard shortcuts

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