dbschema/schema.go

49 lines
933 B
Go
Raw Permalink Normal View History

/*
Package dbschema is used to keep the SQL schema up to date.
func sqlProvider(dbName string, version int) (sql []byte, found bool) {
// read an SQL file and return the contents
return
}
upgrader := dbschema.NewUpgrader()
upgrader.SetSqlCallback(sqlProvider)
if err = upgrader.AddDatabase("127.0.0.1", 5432, "foo", "postgres", "password"); err != nil {
panic(err)
}
if err = upgrader.Run(); err != nil {
panic(err)
}
*/
2023-08-01 17:10:35 +02:00
package dbschema
import (
// External
_ "github.com/lib/pq"
// Standard
"database/sql"
)
// An upgrader verifies the schema for one or more databases and upgrades them if possible.
2023-08-01 17:10:35 +02:00
type Upgrader struct {
databases map[string]Database
logCallback func(string, string)
sqlCallback func(string, int) ([]byte, bool)
}
type Database struct {
Host string
Port int
DbName string
Username string
Password string
db *sql.DB
upgrader *Upgrader
2023-08-01 17:10:35 +02:00
}
// vim: foldmethod=marker