Documentation ¶
Index ¶
Constants ¶
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 AppendSchema ¶
Types ¶
type SchemaUpdate ¶
type SchemaUpdate struct {
// contains filtered or unexported fields
}
SchemaUpdate holds the configuration for executing schema updates.
func Schema ¶
func Schema() *SchemaUpdate
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) 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)
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
}
func NewSchema ¶
func NewSchema() *SchemaUpdateManager
func (*SchemaUpdateManager) AppendSchema ¶
func (m *SchemaUpdateManager) AppendSchema(extensions []schema.Update)
func (*SchemaUpdateManager) Schema ¶
func (m *SchemaUpdateManager) Schema() *SchemaUpdate
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.