dynport / migs

Simple library for go migrations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:Apache License 2.0


Languages

Language:Go 95.6%Language:Shell 3.9%Language:Makefile 0.5%