A golang library for updating your database schema
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
Nise Void f39c1c640a
Support non-PostgreSQL databases
il y a 1 an
.gitignore Initial commit il y a 4 ans
LICENSE Initial commit il y a 4 ans
README.md Fixed issues in README and documentation il y a 4 ans
migrate.go Support non-PostgreSQL databases il y a 10 mois
query.go Support non-PostgreSQL databases il y a 10 mois
util.go Support non-PostgreSQL databases il y a 10 mois

README.md

Go database migrate

This is a simple database migration library for Go. This library is intended to be used with go-bindata.

We recommended using a go generate command to update the go-bindata file.

Installation

You can install this library with go get

go get git.fuyu.moe/Fuyu/migrate

Example

files/0001.sql:

CREATE TABLE tests (
	Name varchar(100) NOT NULL
);

INSERT INTO tests VALUES ('migration test');

Run go-bindata --prefix files files

Optionally you can add the flags -nomemcopy and -nometadata

main.go:

package main

import (
	"database/sql"
	"fmt"

	"git.fuyu.moe/Fuyu/migrate"
	_ "github.com/lib/pq"
)

func main() {
	db, err := sql.Open(`postgres`, `host=/run/postgresql dbname=testdb sslmode=disable`)
	if err != nil {
		fmt.Println(`Failed to connect to database. Message:`, err)
		return
	}
	err = migrate.Migrate(db, 1, migrate.Options{Schema: `testschema`}, Asset)
	if err != nil {
		fmt.Println(`The migration failed! Message:`, err)
		return
	}

	fmt.Println(`The database migration/update was successful`)
}

File names:

The names of your migration files should look like this:

0001.sql
0002.sql
...
0010.sql
...
0325.sql