Add database schema for trips, students, parents, and constraints

This commit is contained in:
Ian Gulliver
2026-02-14 20:59:03 -08:00
parent b33cf94151
commit 45f4332539
2 changed files with 53 additions and 0 deletions

View File

@@ -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) {