Documentation
¶
Overview ¶
Package sensurer provides a simple interface to keep the application database schema up to date. It currently only assists in maintaining the schema to the most up-to-date version. It uses SQL99 compliant DDL and query language so it should work with any DBMS supporting SQL99.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SchemaEnsurer ¶
type SchemaEnsurer struct {
//Database connection
DB *sql.DB
//Keys should be labels for the migrations (will be executed in alphanumeric order)
//Values should be an array of SQL statements
Migrations map[string][]string
//Logger to log debug statements to (the migrations being executed)
Log *log.Logger
}
func New ¶
New returns a new SchemaEnsurer struct initialized with the given db, migrations, and logger. See struct definition for argument descriptions.
func (*SchemaEnsurer) EnsureSchema ¶
func (me *SchemaEnsurer) EnsureSchema() error
EnsureSchema first creates the schema_migrations table if it does not exist and then determines which migrations have not been applied to the database and applies them. It returns any error that occurred while migrating.
