Something went wrong. Try again.
spool is a community-first, lightweight discussion forum, issue tracker, and announcement hub for your project.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667import "../env.js";import { devGithubId } from "../auth/dev.js";import { db, runMigrations } from "./index.js";import { comments, issues, messages, spools, users } from "./schema.js";
runMigrations();
const existing = await db.select({ id: spools.id }).from(spools).limit(1);if (existing.length > 0) { console.log("Database already has spools — skipping seed."); process.exit(0);}
// Same ids the /auth/dev/:username impersonation route generates, so signing// in as "ada" or "grace" reuses these exact users.const [ada] = await db .insert(users) .values({ githubId: devGithubId("ada"), username: "ada", avatarUrl: null }) .returning();const [grace] = await db .insert(users) .values({ githubId: devGithubId("grace"), username: "grace", avatarUrl: null }) .returning();
// No demo "Spool" project — that slug is reserved for the real// tangled.sh/subtype.space/spool repo, synced in automatically when its// owner logs in via AT Proto (see server/src/auth/tangledSync.ts).const [knots] = await db .insert(spools) .values({ slug: "knots-helm", name: "Knots Helm Chart", description: "Helm chart for self-hosting a Knot server on Kubernetes.", repoUrl: null, ownerId: grace.id, }) .returning();
const insertedIssues = await db .insert(issues) .values([ { spoolId: knots.id, number: 1, authorId: grace.id, title: "Chart values for persistent volume size", body: "Hardcoded at 10Gi right now. Should be configurable via values.yaml.", status: "open", }, ]) .returning();
await db.insert(comments).values([ { issueId: insertedIssues[0].id, authorId: ada.id, body: "Should this default to something smaller for local dev, or is 10Gi already the minimum a real deploy needs?", },]);
// Threads: quick drop-in messages, some with later replies.await db.insert(messages).values([ { spoolId: knots.id, authorId: grace.id, body: "Chart v0.2 is up. Persistent volume size is still hardcoded — see the open issue if you want to grab it." },]);
console.log("Seeded 2 users, 1 spool, 1 issue, 1 comment, 1 thread message.");