Database and ORM
Database and ORM tools used by Bunship
Bunship uses Supabase as the default database for managing user information, orders, blogs, and other data. It also supports MySQL, PostgreSQL, and other databases. Currently, Bunship uses Prisma as its ORM, which means any database supported by Prisma can be used.
Supabase Configuration
Creating a Supabase Project
- Visit the Supabase website and sign up/log in
- Create a new project, set a project name and password
- Wait for the project initialization to complete
Getting Connection Information
In the "Database" tab of your project settings, find and copy the following information:
- Database URL
Prisma Configuration
Bunship has pre-configured Prisma, with the configuration file located in prisma/schema.prisma. The Prisma client can be imported from @/lib/prisma.
Initializing Prisma
After cloning the project for the first time, simply run the following command to generate the Prisma client:
Configuring Database Connection
Edit the .env file and add the Supabase database connection information:
schema.prisma File
The prisma/schema.prisma file in the project already includes the basic data models:
Usage
Using in Application
The Prisma client is already configured in @/lib/prisma and can be imported directly:
Database Migrations
When updating data models, run the following commands to update the database structure:
Using Other Databases
Prisma supports multiple databases. Simply modify the provider in schema.prisma:
Then update the connection string in the .env file accordingly.
Common Issues
Database Connection Failed
- Check if the connection string is correct
- Confirm IP whitelist settings
- Verify database user permissions