Skip to content
Source
Sign inSign up
samwillis/one-million-boxes
Open History to see the last commit

init-db.ts

16 lines513 Bytes

1import pg from "pg"
2import { runtimeConfig } from "../server/config"
3import { GameStore } from "../server/store"
4​
5const config = runtimeConfig()
6// Schema setup uses a direct connection and runs once before deployment.
7// initialize() preserves existing tiles and game state.
8const pool = new pg.Pool({
9 connectionString: process.env.DATABASE_URL_UNPOOLED ?? config.databaseUrl,
10})
11try {
12 await new GameStore(pool).initialize()
13 console.log("Game schema and tiles are ready.")
14} finally {
15 await pool.end()