This project uses Prisma for database schema management, type-safe database access, and migrations.
- Install Prisma CLI:
npm install -g prisma
# or using your preferred package manager- Install dependencies:
cd schema
pnpm install- Set up environment variables:
Make sure your
DATABASE_URLis properly configured in your environment:
export DATABASE_URL="postgresql://username:password@localhost:5432/your_database"- Generate Prisma Client:
cd schema
pnpm exec prisma generatecd schema
pnpm exec prisma generatecd schema
# Create a new migration
pnpm exec prisma migrate dev --name "description_of_changes"
# Apply migrations to production
pnpm exec prisma migrate deploycd schema
pnpm exec prisma db pullcd schema
pnpm exec prisma db pushcd schema
pnpm exec prisma migrate resetcd schema
pnpm exec prisma studioThis schema includes the following models:
- Company - Comprehensive company data with financial information (2018-2023)
- Leader - Company leadership and management information
- City - City reference data for autocomplete
- IndustrySector - Industry sector classifications
- LegalForm - Legal form types
- Region - Geographic regions
- UserCompanyStatus - User interaction tracking with companies
- UserQuota - User quota management system
- AppSettings - System configuration settings
This project has been migrated from SQLAlchemy + Alembic to Prisma. Key benefits:
- Type Safety: Auto-generated, fully typed database client
- Better DX: Intuitive query API and excellent IntelliSense
- Database GUI: Built-in Prisma Studio for data exploration
- Migration Management: Robust migration system with rollback support
- Multi-language Support: Works with JavaScript, TypeScript, Python, and more
- I don't like Python: I understand Python but I don't like it and I prefer TypeScript
- All SQLAlchemy models converted to Prisma schema
- Preserved all existing indexes and constraints
- Maintained database compatibility (same table names and structure)
- Enhanced with proper relations between models
- Always run
prisma generateafter modifying the schema file - Use
prisma migrate devduring development for schema changes - Use
prisma migrate deployfor production deployments - Backup your database before running
prisma migrate reset - Check the generated client in
./generated/prismafor available methods - Use Prisma Studio (
prisma studio) for easy data visualization and editing - Make sure the correct
DATABASE_URLis set in your environment variables