webrune-tim / webrune-tim/The-Autonomy-Protocol

Centralize Database Layer into Monorepo Package (`@autonomy/db`)

Open
#46 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

database hacktoberfest help wanted
Dominant language
JavaScript
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Consolidate schema, migrations, and Drizzle config into @autonomy/db
1. Problem Statement

Currently, sites/student-site/src/lib/server/db/ and sites/teacher-site/src/lib/server/db/ contain duplicate schemas and separate drizzle.config.ts files. Both sites maintain independent drizzle/ migration directories (0001_perfect_charles_xavier.sql exists only on student-site). Running migrations from both repositories against a shared Turso database leads to race conditions, schema drift, and duplicate migrations.

2. Scope of Work
  • Create a new monorepo package: packages/core/db (or packages/db) named @autonomy/db.
  • Consolidate all Drizzle schema files (auth.schema.ts, schema.ts, relations) into the new package.
  • Relocate migration generation (drizzle-kit generate), migrations execution (drizzle-kit migrate), and Drizzle Studio into @autonomy/db.
  • Export a typed client and repository helpers consumable by both student-site and teacher-site.
  • Update package.json workspaces and Turborepo pipeline tasks (turbo.json) so database build/check tasks run deterministically.
3. Acceptance Criteria
  • sites/student-site and sites/teacher-site import schemas and db client from @autonomy/db.
  • Only one canonical drizzle/ directory exists in the entire monorepo.
  • Running pnpm --filter @autonomy/db db:migrate successfully applies all migrations cleanly to a blank SQLite/Turso database.
  • Both applications pass pnpm check and pnpm build using the shared package.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare the duplicate database code under sites/student-site/src/lib/server/db/ and sites/teacher-site/src/lib/server/db/, including their drizzle.config.ts and drizzle/ directories. Then review packages/core/db or packages/db, the workspace package.json files, and turbo.json before choosing the package location. Done means both sites import the shared schema and client, one canonical drizzle/ directory remains, the db:migrate command works on a blank database, and both sites pass pnpm check and pnpm build.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite, typescript
Domain
build-system, database
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.