From 12ae2f59795443fbf64b5a655d731583f8cbfe89 Mon Sep 17 00:00:00 2001 From: Ava Gaiety W Date: Wed, 13 Nov 2024 18:52:20 -0700 Subject: [PATCH] Cleanup contrib.md, mv seed data to data dir --- CONTRIBUTING.md | 14 +++++++++++--- src/db/data/index.ts | 4 ++++ src/db/{ => data}/publishers.ts | 2 +- src/db/{ => data}/sources.ts | 2 +- src/db/index.ts | 3 +-- 5 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/db/data/index.ts rename src/db/{ => data}/publishers.ts (81%) rename src/db/{ => data}/sources.ts (82%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5323e73..1a287f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,8 +14,16 @@ - Drizzle - DrizzleKit -### Updating Data +### Updating the Database (DB) -Data is stored in `./db.sqlite` +Data is stored in `./db.sqlite`, **but do not modify that file manually.** -To update it, modify the files in `./src/db` and run `bun src/db/index.ts`. +### To update the data within the tables + +Update the files in `./src/db/data` +Then run `bun drizzle-kit push` + +### To update the schema + +Update the file in `./src/schema.ts` +Then run `bun src/db/index.ts` diff --git a/src/db/data/index.ts b/src/db/data/index.ts new file mode 100644 index 0000000..3074486 --- /dev/null +++ b/src/db/data/index.ts @@ -0,0 +1,4 @@ +import publishers from './publishers' +import sources from './sources' + +export { publishers, sources } diff --git a/src/db/publishers.ts b/src/db/data/publishers.ts similarity index 81% rename from src/db/publishers.ts rename to src/db/data/publishers.ts index 1160b8e..bca0eb0 100644 --- a/src/db/publishers.ts +++ b/src/db/data/publishers.ts @@ -1,4 +1,4 @@ -import { publisherTable } from './schema'; +import { publisherTable } from '../schema'; type Publisher = typeof publisherTable.$inferInsert; diff --git a/src/db/sources.ts b/src/db/data/sources.ts similarity index 82% rename from src/db/sources.ts rename to src/db/data/sources.ts index b7514c1..819f2f9 100644 --- a/src/db/sources.ts +++ b/src/db/data/sources.ts @@ -1,4 +1,4 @@ -import { sourceTable } from './schema'; +import { sourceTable } from '../schema'; type Source = typeof sourceTable.$inferInsert; diff --git a/src/db/index.ts b/src/db/index.ts index 1c10c0d..c229c76 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -1,8 +1,7 @@ import 'dotenv/config'; import { drizzle } from 'drizzle-orm/bun-sqlite'; import { publisherTable, sourceTable } from './schema'; -import publishers from './publishers'; -import sources from './sources'; +import { publishers, sources } from './data' const db = drizzle({ connection: { source: process.env.DB_FILE_NAME! } });