1
0
Fork 0

Cleanup contrib.md, mv seed data to data dir

This commit is contained in:
Ava Gaiety W 2024-11-13 18:52:20 -07:00
parent 4027bab5fb
commit 12ae2f5979
5 changed files with 18 additions and 7 deletions

View file

@ -14,8 +14,16 @@
- Drizzle - Drizzle
- DrizzleKit - 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`

4
src/db/data/index.ts Normal file
View file

@ -0,0 +1,4 @@
import publishers from './publishers'
import sources from './sources'
export { publishers, sources }

View file

@ -1,4 +1,4 @@
import { publisherTable } from './schema'; import { publisherTable } from '../schema';
type Publisher = typeof publisherTable.$inferInsert; type Publisher = typeof publisherTable.$inferInsert;

View file

@ -1,4 +1,4 @@
import { sourceTable } from './schema'; import { sourceTable } from '../schema';
type Source = typeof sourceTable.$inferInsert; type Source = typeof sourceTable.$inferInsert;

View file

@ -1,8 +1,7 @@
import 'dotenv/config'; import 'dotenv/config';
import { drizzle } from 'drizzle-orm/bun-sqlite'; import { drizzle } from 'drizzle-orm/bun-sqlite';
import { publisherTable, sourceTable } from './schema'; import { publisherTable, sourceTable } from './schema';
import publishers from './publishers'; import { publishers, sources } from './data'
import sources from './sources';
const db = drizzle({ connection: { source: process.env.DB_FILE_NAME! } }); const db = drizzle({ connection: { source: process.env.DB_FILE_NAME! } });