Initial commit

This commit is contained in:
2026-04-06 15:48:37 -05:00
commit a09ccf639e
8 changed files with 5588 additions and 0 deletions

12
init/01-schema.sql Normal file
View File

@@ -0,0 +1,12 @@
CREATE TABLE puzzles (
PuzzleId TEXT PRIMARY KEY,
FEN TEXT,
Moves TEXT,
Rating INTEGER,
RatingDeviation INTEGER,
Popularity INTEGER,
NbPlays INTEGER,
Themes TEXT,
GameUrl TEXT,
OpeningTags TEXT
);

11
init/02-import.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
echo "Importing CSV into puzzles table..."
psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" <<EOF
COPY puzzles(PuzzleId,FEN,Moves,Rating,RatingDeviation,Popularity,NbPlays,Themes,GameUrl,OpeningTags)
FROM '/data/puzzles.csv'
DELIMITER ','
CSV HEADER;
EOF

5
init/03_add_pkey.sql Normal file
View File

@@ -0,0 +1,5 @@
-- Drop the existing primary key
ALTER TABLE puzzles DROP CONSTRAINT puzzles_pkey;
-- Add new auto-incrementing primary key while keeping PuzzleId
ALTER TABLE puzzles ADD COLUMN pkey BIGSERIAL PRIMARY KEY;