package dbschema import ( // External _ "github.com/lib/pq" // Standard "database/sql" ) type Upgrader struct { schemaDb Database 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 schemaDb *Database } /* func dbUpdate() (err error) {// {{{ var rows *sqlx.Rows var schemaStr string var schema int rows, err = db.Queryx(`SELECT value FROM _internal.db WHERE "key"='schema'`) if err != nil { return } defer rows.Close() if !rows.Next() { return errors.New("Table _interval.db missing schema row") } if err = rows.Scan(&schemaStr); err != nil { return } // Run updates schema, err = strconv.Atoi(schemaStr) if err != nil { return err } for i := (schema+1); i <= DB_SCHEMA; i++ { log.Printf("\x1b[32mNotes\x1b[0m Upgrading SQL schema to revision %d...", i) sql, _ := embedded.ReadFile( fmt.Sprintf("sql/%04d.sql", i), ) _, err = db.Exec(string(sql)) if err != nil { return } _, err = db.Exec(`UPDATE _internal.db SET "value"=$1 WHERE "key"='schema'`, i) if err != nil { return } log.Printf("\x1b[32mNotes\x1b[0m OK: %d", i) } return }// }}} */ // vim: foldmethod=marker