sql

package
v0.0.0-...-dae269f Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// "mysql"-compatible executable for raw sql queries
	SQLQueryExecutable = "mariadb"

	// "mysqldump"-compatible executable for dumping an entire database
	SQlDumpExecutable = "mariadb-dump"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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
	Dependencies struct {
		Tables []component.Table
	}

	ServerURL string // upstream server url

	PollInterval time.Duration // duration to wait for during wait
}

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, name, user, password string) error

CreateDatabase creates a new database with the given name. It then generates a new user, with the name 'user' and the password 'password', that is then granted 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) error

CreateSuperuser createsa new user, with the name 'user' and the password 'password'. It then grants this user superuser status in the database.

CreateSuperuser internally waits for the database to become available.

func (*SQL) Exec

func (sql *SQL) Exec(query string, args ...interface{}) error

Exec executes a database-independent database query.

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

func (sql *SQL) PurgeDatabase(db string) error

SQLPurgeDatabase deletes the specified db from the database

func (*SQL) PurgeUser

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

SQLPurgeUser deletes the specified user from the database

func (*SQL) QueryTable

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

QueryTable returns a gorm.DB to connect to the provided table of the given model

func (*SQL) Shell

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

Shell runs a mysql shell with the provided databases.

NOTE(twiesing): This command should not be used to connect to the database or execute queries except in known situations.

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

func (sql *SQL) Stack() component.StackWithResources

func (*SQL) Update

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

Update initializes or updates the SQL database.

func (*SQL) WaitQueryTable

func (sql *SQL) WaitQueryTable(ctx context.Context) error

WaitQueryTable waits for a connection to succeed via QueryTable

Jump to

Keyboard shortcuts

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