Add database schema for trips, students, parents, and constraints
This commit is contained in:
8
main.go
8
main.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -10,6 +11,9 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
//go:embed schema.sql
|
||||
var schema string
|
||||
|
||||
func main() {
|
||||
dsn := os.Getenv("PGCONN")
|
||||
if dsn == "" {
|
||||
@@ -27,6 +31,10 @@ func main() {
|
||||
}
|
||||
log.Println("connected to database")
|
||||
|
||||
if _, err := db.Exec(schema); err != nil {
|
||||
log.Fatalf("failed to apply schema: %v", err)
|
||||
}
|
||||
|
||||
http.Handle("/", http.FileServer(http.Dir("static")))
|
||||
|
||||
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user