sql

package
v0.0.0-...-d8aad48 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenInterface

func OpenInterface[T any](ctx context.Context, sql *SQL, table component.Table) (gorm.Interface[T], error)

OpenInterface opens a gorm.Interface to the given sql and table interface. The generic parameter T must correspond to the component.Table's TableInfo.

Types

type CreateOpts

type CreateOpts struct {
	Name        string // Name of the database to create
	AllowExists bool   // Don't error if the database already exists

	CreateUser bool // Create an appropriate database user
	Username   string
	Password   string
}

CreateOpts are options for CreateOpts.

func (CreateOpts) Validate

func (cd CreateOpts) Validate() error

type InstanceTable

type InstanceTable struct {
	component.Base
}

func (*InstanceTable) TableInfo

func (*InstanceTable) TableInfo() component.TableInfo

type LockTable

type LockTable struct {
	component.Base
}

func (*LockTable) TableInfo

func (*LockTable) TableInfo() component.TableInfo

type SQL

type SQL struct {
	component.Base

	ServerURL string // upstream server url

	PollInterval time.Duration // duration to wait for during wait
	// contains filtered or unexported fields
}

func (*SQL) Backup

func (sql *SQL) Backup(scontext *component.StagingContext) error

Backup makes a backup of all SQL databases into the path dest.

func (*SQL) BackupName

func (*SQL) BackupName() string

func (*SQL) CreateDatabase

func (sql *SQL) CreateDatabase(ctx context.Context, opts CreateOpts) error

CreateDatabase creates a new database with the given name. If the user name is not the empty string, it then generates a new user and grants access to this database.

Provision internally waits for the database to become available.

func (*SQL) CreateSuperuser

func (sql *SQL) CreateSuperuser(ctx context.Context, user, password string, allowExisting bool) (e error)

CreateSuperuser createsa new user, with the name 'user' and the password 'password'. CreateSuperuser always waits for the database to become available, and then uses the internal 'mysql' executable of the container.

func (*SQL) DropDatabase

func (sql *SQL) DropDatabase(ctx context.Context, db string) error

Drops the given database if it exists.

func (*SQL) DropUser

func (sql *SQL) DropUser(ctx context.Context, user string) error

DropUser drops the given user if it exists.

func (*SQL) OpenStack

func (sql *SQL) OpenStack() (component.StackWithResources, error)

func (*SQL) OpenTable

func (sql *SQL) OpenTable(ctx context.Context, table component.Table) (*gorm.DB, error)

OpenTable opens a *gorm.DB connection to the given table. Should use OpenInterface where possible.

TODO: Migrate everything here!

func (*SQL) Path

func (sql *SQL) Path() string

func (*SQL) Provision

func (sql *SQL) Provision(ctx context.Context, instance models.Instance, domain string) error

Provision provisions sql-specific resource for the given instance.

func (*SQL) Purge

func (sql *SQL) Purge(ctx context.Context, instance models.Instance, domain string) error

Purge purges sql-specific resources for the given instance.

func (*SQL) Query

func (sql *SQL) Query(ctx context.Context, query string, args ...interface{}) (e error)

Query executes a database-independent query.

func (*SQL) Shell

func (sql *SQL) Shell(ctx context.Context, io stream.IOStream, argv ...string) int

Shell directly executes a mysql command inside the container. This command should be used with caution.

func (*SQL) Snapshot

func (sql *SQL) Snapshot(wisski models.Instance, scontext *component.StagingContext) error

func (*SQL) SnapshotDB

func (sql *SQL) SnapshotDB(ctx context.Context, progress io.Writer, dest io.Writer, database string) (e error)

SnapshotDB makes a backup of the sql database into dest.

func (*SQL) SnapshotName

func (*SQL) SnapshotName() string

func (*SQL) SnapshotNeedsRunning

func (*SQL) SnapshotNeedsRunning() bool

func (*SQL) Update

func (sql *SQL) Update(ctx context.Context, progress io.Writer) error

Update initializes or updates the SQL database.

func (*SQL) Wait

func (sql *SQL) Wait(ctx context.Context) (err error)

Wait waits for the connection to the distillery-specific database to succeed.

Jump to

Keyboard shortcuts

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