forked from electricdusk/rushlink
Automigrate when opening db
This commit is contained in:
parent
1ecb11c65f
commit
f527f2fb38
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"gitea.hashru.nl/dsprenkels/rushlink"
|
||||
"gitea.hashru.nl/dsprenkels/rushlink/internal/db"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -26,6 +27,11 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
migrate := db.Gormigrate(database)
|
||||
if err := migrate.Migrate(); err != nil {
|
||||
log.Fatal(errors.Wrap(err, "migrating database"))
|
||||
}
|
||||
|
||||
go rushlink.StartMetricsServer(*metricsListen, database, filestore)
|
||||
rushlink.StartMainServer(*httpListen, database, filestore, *rootURL)
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ func OpenTemporaryDB() (*Database, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
migrate := Gormigrate(db)
|
||||
if err := migrate.Migrate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return db, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user