Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

migs

Simple library for go migrations. Supports plain text SQL statements and also functions.

Usage

package migs

import (
	"database/sql"
	"log"
)

func runMigrations(tx *sql.Tx) {
	migs := New(
		"CREATE TABLE users (id SERIAL NOT NULL PRIMARY KEY, email VARCHAR)",
		migrationFunc, // allow executing functions as well
	)
	err := migs.ExecuteTx(tx)
	if err != nil {
		log.Fatal(err)
	}
}

func migrationFunc(tx Con) error {
	_, err := tx.Exec("INSERT INTO users (email) VALUES ($1)", "tobias@phraseapp.com")
	return err
}

About

Simple library for go migrations

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages