Documentation
¶
Overview ¶
package lazymigrate allows for simple SQLite migrations by using a magic comment to delimit different versions of the schema.
Index ¶
Constants ¶
const Delimiter = "--------------------------------- NEW VERSION ---------------------------------"
Delimiter is the default delimiter for the schema string. It is intentionally long and ugly to avoid collisions.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema wraps a SQLite schema string. A schema string is a series of SQL statements that create and modify tables. The schema string is delimited by a configurable magic comment. The magic comment must be on its own line before and after the schema string. It must not appear at the start or end of the schema string.
func NewSchema ¶
NewSchema returns a new Schema with the given schema string. The schema string is delimited by the default magic comment Delimiter.
func NewSchemaWithMagic ¶
NewSchemaWithMagic returns a new Schema with the given schema string and magic comment.
func (*Schema) Migrate ¶
Migrate migrates the database at the given source to the latest migrations. It uses the user_version pragma. Note that the function does not set any pragma values except for user_version. If you need to set other pragmas, you must do so yourself.
The migrations are all done in a single transaction. If any migration fails, the transaction is rolled back and the error is returned.