Skip to content

interactive-solutions/go-sql-migrations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Go migrations

A simple library with the primary objective of being injected into projects startup executes a set of migration files based upon version name and name.

Example integration

package main

import (
	"github.com/interactive-solutions/go-sql-migrations"
	"github.com/interactive-solutions/go-sql-migrations/driver"
)

func migrate(host, user, password, dbname string) {

	url := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", host, user, password, dbname)

	conn, err := sqlx.Connect("driver", url)
	if err != nil {
		panic(err)
	}

	defer conn.Close()

	mig := migrations.CreateFromDirectory("./pkg/database/postgres/migrations")
	mig.Up(driver.NewPostgresDriver(conn))
}

Todo list

  • Add a utility method to create a migration file from current time and provide path
  • Migrate down x versions

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages