Spaces:
Running
Running
Download src/seed/setup.ts from risenetup/chess-monolith: direct link, hf CLI and curl.
- Browser
- Download file 883 Bytes
-
https://huggingface.co/spaces/risenetup/chess-monolith/resolve/main/src/seed/setup.ts
- Command line
-
hf download hf://spaces/risenetup/chess-monolith/src/seed/setup.ts
-
curl -L -o setup.ts https://huggingface.co/spaces/risenetup/chess-monolith/resolve/main/src/seed/setup.ts
883 Bytes
| import postgres from "postgres"; | |
| import { env } from "../config/env"; | |
| import fs from "fs"; | |
| import crypto from "crypto"; | |
| import "dotenv/config"; | |
| const sql = postgres(env.DATABASE_URL!); | |
| async function main() { | |
| try { | |
| await sql`CREATE EXTENSION IF NOT EXISTS pg_trgm;`; | |
| console.log("Extension 'pg_trgm' created or already exists."); | |
| const migrationSQL = fs.readFileSync( | |
| "./drizzle/0000_rainy_hedge_knight.sql", | |
| "utf8", | |
| ); | |
| const hash = crypto.createHash("sha256").update(migrationSQL).digest("hex"); | |
| await sql` | |
| INSERT INTO drizzle.__drizzle_migrations (hash, created_at) | |
| VALUES (${hash}, ${Date.now()}) | |
| ON CONFLICT DO NOTHING | |
| `; | |
| console.log("✅ Migration marked as applied"); | |
| await sql.end(); | |
| } catch (error) { | |
| console.error("Failed to create extension:", error); | |
| } finally { | |
| process.exit(0); | |
| } | |
| } | |
| main(); | |