freshyo/packages/db_helper_postgres
2026-03-25 01:43:02 +05:30
..
drizzle enh 2026-03-24 20:50:14 +05:30
src enh 2026-03-25 01:43:02 +05:30
.env enh 2026-03-24 20:50:14 +05:30
.env.example enh 2026-03-24 20:50:14 +05:30
drizzle.config.ts enh 2026-03-24 20:50:14 +05:30
index.ts enh 2026-03-25 01:43:02 +05:30
package.json enh 2026-03-24 20:50:14 +05:30
README.md enh 2026-03-24 20:50:14 +05:30
tsconfig.json enh 2026-03-24 20:50:14 +05:30

Database Helper - PostgreSQL

This package contains all database-related configuration, migrations, and schema definitions for the PostgreSQL database.

Structure

  • src/db/ - Database source files
    • schema.ts - Drizzle ORM schema definitions
    • db_index.ts - Database connection and client setup
    • types.ts - Database types
    • seed.ts - Database seeding script
    • porter.ts - Data migration utilities
  • drizzle/ - Migration files generated by Drizzle Kit
  • drizzle.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 files
  • npm run db:push - Push schema changes to database
  • npm run db:seed - Run database seeding
  • npm 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';