Skip to content

dynport/migs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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)", "[email protected]")
	return err
}

About

Simple library for go migrations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published