Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeSet ¶
type ChangeSet struct {
Current, Post int
}
ChangeSet returns the schema changes for the schema when they're applied.
type Patch ¶
type Patch struct {
// contains filtered or unexported fields
}
Patch applies a specific schema change to a database, and returns an error if anything goes wrong.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema captures the schema of a database in terms of a series of ordered updates.
func (*Schema) Add ¶
Add a new update to the schema. It will be appended at the end of the existing series.
func (*Schema) Ensure ¶
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 current (currently applied updates are tracked in the a 'schema' 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 (*Schema) Hook ¶
Hook instructs the schema to invoke the given function whenever a update is about to be applied. The function gets passed the update version number and the running transaction, and if it returns an error it will cause the schema transaction to be rolled back. Any previously installed hook will be replaced.