update

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CreateSchema = `` /* 198-byte string literal not displayed */

CreateSchema is the default schema applied when bootstrapping the database.

Variables

This section is empty.

Functions

func GetClusterMemberAPIExtensions

func GetClusterMemberAPIExtensions(ctx context.Context, tx *sql.Tx) ([]extensions.Extensions, error)

GetClusterMemberAPIExtensions returns the API extensions from all cluster members that are not pending. This helper is non-generated to work before generated statements are loaded, as we update the API extensions.

func GetClusterMemberSchemaVersions

func GetClusterMemberSchemaVersions(ctx context.Context, tx *sql.Tx) (internalSchema []uint64, externalSchema []uint64, err error)

GetClusterMemberSchemaVersions returns the schema versions from all cluster members that are not pending. This helper is non-generated to work before generated statements are loaded, as we update the schema.

func PrepareUpdateV1

func PrepareUpdateV1(ctx context.Context, tx *sql.Tx) (tableName string, err error)

PrepareUpdateV1 creates the temporary table `internal_cluster_members_new` if we have not yet run `updateFromV1`. To keep this table in sync with `internal_cluster_members`, a create & update trigger is created as well. This table (and its triggers) will be deleted by `updateFromV1`.

func UpdateClusterMemberAPIExtensions

func UpdateClusterMemberAPIExtensions(ctx context.Context, tx *sql.Tx, apiExtensions extensions.Extensions, memberName string) error

UpdateClusterMemberAPIExtensions sets the API extensions for the cluster member with the given address. This helper is non-generated to work before generated statements are loaded, as we update the API extensions.

func UpdateClusterMemberSchemaVersion

func UpdateClusterMemberSchemaVersion(ctx context.Context, tx *sql.Tx, internalVersion uint64, externalVersion uint64, memberName string) error

UpdateClusterMemberSchemaVersion sets the schema version for the cluster member with the given address. This helper is non-generated to work before generated statements are loaded, as we update the schema.

Types

type SchemaUpdate

type SchemaUpdate struct {
	// contains filtered or unexported fields
}

SchemaUpdate holds the configuration for executing schema updates.

func (*SchemaUpdate) Check

func (s *SchemaUpdate) Check(check schema.Check)

Check instructs the schema to invoke the given function whenever Ensure is invoked, before applying any due update. It can be used for aborting the operation.

func (*SchemaUpdate) Ensure

func (s *SchemaUpdate) Ensure(db *sql.DB) (int, error)

Ensure makes sure that the actual schema in the given database matches the one defined by our updates.

All updates are applied transactionally. In case any error occurs the transaction will be rolled back and the database will remain unchanged.

A update will be applied only if it hasn't been before (currently applied updates are tracked in the a 'shema' table, which gets automatically created).

If no error occurs, the integer returned by this method is the initial version that the schema has been upgraded from.

func (*SchemaUpdate) File

func (s *SchemaUpdate) File(path string)

File sets the schema update's path for extra queries to run before schema updates are applied.

func (*SchemaUpdate) Fresh

func (s *SchemaUpdate) Fresh(statement string)

Fresh sets a statement that will be used to create the schema from scratch when bootstraping an empty database. It should be a "flattening" of the available updates, generated using the Dump() method. If not given, all patches will be applied in order.

func (*SchemaUpdate) Version

func (s *SchemaUpdate) Version() (internalVersion uint64, externalVersion uint64, apiExtensions extensions.Extensions)

Version returns the internal and external schema update versions, corresponding to the number of updates that have occurred.

type SchemaUpdateManager

type SchemaUpdateManager struct {
	// contains filtered or unexported fields
}

SchemaUpdateManager contains a map of schema update type to slice of schema.Update.

func NewSchema

func NewSchema() *SchemaUpdateManager

NewSchema returns a new SchemaUpdateManager containing microcluster schema updates.

func (*SchemaUpdateManager) AppendSchema

func (s *SchemaUpdateManager) AppendSchema(schemaExtensions []schema.Update, apiExtensions extensions.Extensions)

AppendSchema sets the given schema and API updates as the list of external extensions on the update manager.

func (*SchemaUpdateManager) Schema

func (s *SchemaUpdateManager) Schema() *SchemaUpdate

Schema returns a SchemaUpdate from the SchemaUpdateManager config.

func (*SchemaUpdateManager) SetExternalUpdates

func (s *SchemaUpdateManager) SetExternalUpdates(updates []schema.Update)

SetExternalUpdates replaces the set of external schema updates.

func (*SchemaUpdateManager) SetInternalUpdates

func (s *SchemaUpdateManager) SetInternalUpdates(updates []schema.Update)

SetInternalUpdates replaces the set of internal schema updates.

Jump to

Keyboard shortcuts

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