Beispiel #1
0
func TestMigrations(t *testing.T) {
	logger := NullLogger()
	dbh := NewMemoryDBHandle(logger, true)
	migrator, err := gomigrate.NewMigratorWithMigrations(dbh.db.DB, gomigrate.Sqlite3{}, SchemaMigrations())
	if err != nil {
		t.Fatal(err)
	}

	migrator.Logger = logger
	err = migrator.Migrate()

	if err != nil {
		t.Fatal(err)
	}

	migrator, err = gomigrate.NewMigratorWithMigrations(dbh.db.DB, gomigrate.Sqlite3{}, TestFixtures())
	if err != nil {
		t.Fatal(err)
	}

	migrator.Logger = logger
	err = migrator.Migrate()

	if err != nil {
		t.Fatal(err)
	}
}
Beispiel #2
0
// Migrate uses the migrations at the given path to update the database.
func (d *Handle) Migrate(m []*gomigrate.Migration) error {
	migrator, err := gomigrate.NewMigratorWithMigrations(d.db.DB, gomigrate.Sqlite3{}, m)
	if err != nil {
		return err
	}
	migrator.Logger = d.logger
	err = migrator.Migrate()
	return err
}