Documentation ¶
Index ¶
- Constants
- Variables
- type AdminClient
- type Client
- func (c *Client) ApplyDDL(ctx context.Context, statements []string) error
- func (c *Client) ApplyDDLFile(ctx context.Context, filename string, ddl []byte) error
- func (c *Client) ApplyDML(ctx context.Context, statements []string, priority PriorityType) (int64, error)
- func (c *Client) ApplyDMLFile(ctx context.Context, filename string, ddl []byte, partitioned bool, ...) (int64, error)
- func (c *Client) ApplyPartitionedDML(ctx context.Context, statements []string, priority PriorityType) (int64, error)
- func (c *Client) Close() error
- func (c *Client) CreateDatabase(ctx context.Context, filename string, ddl []byte) error
- func (c *Client) DropDatabase(ctx context.Context) error
- func (c *Client) EnsureMigrationTable(ctx context.Context, tableName string) error
- func (c *Client) ExecuteMigrations(ctx context.Context, migrations Migrations, limit int, tableName string) error
- func (c *Client) GetSchemaMigrationVersion(ctx context.Context, tableName string) (uint, bool, error)
- func (c *Client) LoadDDL(ctx context.Context) ([]byte, error)
- func (c *Client) SetSchemaMigrationVersion(ctx context.Context, version uint, dirty bool, tableName string) error
- func (c *Client) TruncateAllTables(ctx context.Context) error
- type Config
- type Error
- type ErrorCode
- type Migration
- type Migrations
- type PriorityType
Constants ¶
View Source
const ( ErrorCodeCreateClient = iota + 1 ErrorCodeCloseClient ErrorCodeCreateDatabase ErrorCodeDropDatabase ErrorCodeTruncateAllTables ErrorCodeLoadSchema ErrorCodeUpdateDDL ErrorCodeUpdateDML ErrorCodeUpdatePartitionedDML ErrorCodeExecuteMigrations ErrorCodeGetMigrationVersion ErrorCodeSetMigrationVersion ErrorCodeNoMigration ErrorCodeMigrationVersionDirty ErrorCodeWaitOperation ErrorCodeCreateInstance ErrorCodeDeleteInstance )
Variables ¶
View Source
var (
MigrationNameRegex = regexp.MustCompile(`[a-zA-Z0-9_\-]+`)
)
Functions ¶
This section is empty.
Types ¶
type AdminClient ¶
type AdminClient struct {
// contains filtered or unexported fields
}
func NewAdminClient ¶
func NewAdminClient(ctx context.Context, config *Config) (*AdminClient, error)
func (*AdminClient) Close ¶
func (c *AdminClient) Close() error
func (*AdminClient) CreateInstance ¶
func (c *AdminClient) CreateInstance(ctx context.Context, node int32) error
func (*AdminClient) DeleteInstance ¶
func (c *AdminClient) DeleteInstance(ctx context.Context, nmae string) error
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) ApplyDDLFile ¶
func (*Client) ApplyDMLFile ¶
func (*Client) ApplyPartitionedDML ¶
func (*Client) CreateDatabase ¶
func (*Client) EnsureMigrationTable ¶
func (*Client) ExecuteMigrations ¶
func (*Client) GetSchemaMigrationVersion ¶
func (*Client) SetSchemaMigrationVersion ¶
type Config ¶
type Config struct { Project string Instance string Database string CredentialsFile string // ClientOptions is options of Spanner clients when creating the clients for both normal // and admin. This options are evaluated first and can be overridden by other // configurations in Wrench. // // Experimental: There will be a breaking change in the future versions. ClientOptions []option.ClientOption }
type Migration ¶
type Migration struct { // Version is the version of the migration Version uint // Name is the name of the migration Name string // Statements is the migration statements Statements []string // contains filtered or unexported fields }
migration represents the parsed migration file. e.g. version_name.sql
type Migrations ¶
type Migrations []*Migration
func LoadMigrations ¶
func LoadMigrations(dir string) (Migrations, error)
func LoadMigrationsFromEmbeddedFS ¶
func LoadMigrationsFromEmbeddedFS(dir string, scripts embed.FS) (Migrations, error)
func (Migrations) Len ¶
func (ms Migrations) Len() int
func (Migrations) Less ¶
func (ms Migrations) Less(i, j int) bool
func (Migrations) Swap ¶
func (ms Migrations) Swap(i, j int)
type PriorityType ¶
type PriorityType int
const ( PriorityTypeUnspecified PriorityType = iota PriorityTypeHigh PriorityTypeMedium PriorityTypeLow )
Click to show internal directories.
Click to hide internal directories.