sql

package
v1.55.9 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Code adapted from https://github.com/jackc/tern/blob/master/migrate/internal/sqlsplit/sqlsplit.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SQLSplit added in v1.50.5

func SQLSplit(sql string) []string

Split splits sql into into a slice of strings each containing one SQL statement.

Types

type DatabaseName added in v1.53.0

type DatabaseName = string

type DatabaseServer added in v1.53.0

type DatabaseServer struct {
	DatabaseName     string
	Status           string
	ResourceRegister *resources.ResourceRegister[resourcespb.SqlDatabaseResource]
	ConnectionString string
}

type DatabaseStatus added in v1.53.0

type DatabaseStatus string
const (
	DatabaseStatusStarting           DatabaseStatus = "starting"
	DatabaseStatusBuildingMigrations DatabaseStatus = "building migrations"
	DatabaseStatusApplyingMigrations DatabaseStatus = "applying migrations"
	DatabaseStatusActive             DatabaseStatus = "active"
	DatabaseStatusError              DatabaseStatus = "error"
)

type LocalSqlServer

type LocalSqlServer struct {
	State State
	sqlpb.UnimplementedSqlServer
	// contains filtered or unexported fields
}

func NewLocalSqlServer

func NewLocalSqlServer(projectName string, localResources *resources.LocalResourcesService, migrationRunner MigrationRunner) (*LocalSqlServer, error)

func (*LocalSqlServer) BuildAndRunMigrations added in v1.53.0

func (l *LocalSqlServer) BuildAndRunMigrations(fs afero.Fs, databasesToMigrate map[string]*resourcespb.SqlDatabaseResource, useBuilder bool) error

func (*LocalSqlServer) ConnectionString

func (*LocalSqlServer) GetState added in v1.53.0

func (l *LocalSqlServer) GetState() State

func (*LocalSqlServer) Publish added in v1.53.0

func (l *LocalSqlServer) Publish(state State)

func (*LocalSqlServer) Query added in v1.49.0

func (l *LocalSqlServer) Query(ctx context.Context, connectionString string, query string) ([]*orderedmap.OrderedMap[string, any], error)

create a function that will execute a query on the local database

func (*LocalSqlServer) RegisterDatabases added in v1.53.0

func (l *LocalSqlServer) RegisterDatabases(lrs resources.LocalResourcesState)

func (*LocalSqlServer) Stop

func (l *LocalSqlServer) Stop() error

func (*LocalSqlServer) SubscribeToState added in v1.53.0

func (l *LocalSqlServer) SubscribeToState(subscriberFunction func(State))

type MigrationRunner added in v1.53.0

type MigrationRunner = func(fs afero.Fs, servers map[string]*DatabaseServer, databasesToMigrate map[string]*resourcespb.SqlDatabaseResource, useBuilder bool) error

type State added in v1.53.0

type State = map[DatabaseName]*DatabaseServer

Jump to

Keyboard shortcuts

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