.. | ||
analyze-schema.ts | ||
bun.lockb | ||
export-problems.ts | ||
insert-problems.ts | ||
package.json | ||
README.md | ||
tsconfig.json |
Migrate Problems
This folder contains scripts to migrate problem data from Replay's WebSocket API to a Supabase database.
Overview
These scripts handle the migration process for problems from Replay to Supabase:
export-problems.ts
- Fetches problems from Replay's API and saves them to JSON filesinsert-problems.ts
- Imports problems from JSON files into the Supabase databaseanalyze-schema.ts
- Analyzes and compares local problem data with the Supabase database schema
Setup
- Create a
.env.local
file in this directory with your Supabase credentials:
SUPABASE_URL=https://your-project-url.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
- Install dependencies:
npm install
# or
bun install
Usage
Export Problems from Replay
Fetches all problems from Replay's WebSocket API and saves them as JSON files in the ../data
directory:
bun export-problems.ts
To include test problems:
bun export-problems.ts --include-test
Analyze Schema
Analyzes the structure of the exported problem files and compares with the Supabase database schema:
bun analyze-schema.ts
Import Problems to Supabase
Imports problems from the data
directory into Supabase:
bun insert-problems.ts
Warning: This script deletes existing problems in the database that don't have "tic tac toe" in their title before importing.
Problem Data Structure
Problems have the following structure:
interface BoltProblem {
version: number;
problemId: string;
timestamp: number;
title: string;
description: string;
status?: string;
keywords?: string[];
username?: string;
user_id?: string;
repositoryContents: string;
comments?: BoltProblemComment[];
solution?: BoltProblemSolution;
}
When imported to Supabase, large fields (repository contents, solutions, prompts) are stored in separate storage buckets.