| .. | ||
| drizzle | ||
| src | ||
| .env | ||
| .env.example | ||
| drizzle.config.ts | ||
| index.ts | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
Database Helper - PostgreSQL
This package contains all database-related configuration, migrations, and schema definitions for the PostgreSQL database.
Structure
src/db/- Database source filesschema.ts- Drizzle ORM schema definitionsdb_index.ts- Database connection and client setuptypes.ts- Database typesseed.ts- Database seeding scriptporter.ts- Data migration utilities
drizzle/- Migration files generated by Drizzle Kitdrizzle.config.ts- Drizzle Kit configuration
Environment Variables
Create a .env file with:
DATABASE_URL=postgresql://username:password@localhost:5432/dbname
Scripts
npm run migrate- Generate new migration filesnpm run db:push- Push schema changes to databasenpm run db:seed- Run database seedingnpm run db:studio- Open Drizzle Studio
Usage
This package can be used by other packages/apps in the monorepo:
import { db } from '@packages/db_helper_postgres/src/db/db_index';
import { users } from '@packages/db_helper_postgres/src/db/schema';