sensurer

package module
v0.0.0-...-f668040 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2013 License: MIT Imports: 3 Imported by: 4

README

Schema Ensurer

Build Status

Simple schema management in Go.

Usage

Please refer to the godoc documentation (http://godoc.org/github.com/modcloth-labs/schema_ensurer).

See test for examples.

Inquiries can be directed to: github+schema_ensurer@modcloth.com

Development

Requires SQLite3 header files to be present for testing.

Requires gosqlite package for testing (go get -v code.google.com/p/gosqlite/sqlite3)

Test via go test github.com/modcloth-labs/schema_ensurer.

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

func New(db *sql.DB, migrations map[string][]string, log *log.Logger) *SchemaEnsurer

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.

Jump to

Keyboard shortcuts

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