mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 22:29:07 +00:00
Setup database migration
This commit is contained in:
@@ -26,10 +26,18 @@ func main() {
|
||||
port = defaultPort
|
||||
}
|
||||
|
||||
database.SetupDatabase()
|
||||
db := database.SetupDatabase()
|
||||
defer db.Close()
|
||||
|
||||
// Migrate database
|
||||
if err := database.MigrateDatabase(db); err != nil {
|
||||
log.Fatalf("Could not migrate database: %s\n", err)
|
||||
}
|
||||
|
||||
graphqlResolver := photoview_graphql.Resolver{Database: db}
|
||||
|
||||
http.Handle("/", handler.Playground("GraphQL playground", "/query"))
|
||||
http.Handle("/query", handler.GraphQL(photoview_graphql.NewExecutableSchema(photoview_graphql.Config{Resolvers: &photoview_graphql.Resolver{}})))
|
||||
http.Handle("/query", handler.GraphQL(photoview_graphql.NewExecutableSchema(photoview_graphql.Config{Resolvers: &graphqlResolver})))
|
||||
|
||||
log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
|
||||
log.Fatal(http.ListenAndServe(":"+port, nil))
|
||||
|
||||
Reference in New Issue
Block a user