# Supabase Project
Create a Project from supabase.com
# Prisma Setup
Add *prisma* dependency to the project
```sh
bun add prisma@latest -D
```
Now initialize prisma in the project with the following command
```sh
bunx prisma init
```
## Add Database url of supabase to prisma
- Copy the Database URL and Direct URL and add it to `.env` file created by prisma
- Add the `Provider` of `data source` to `schema.prisma` file
- There are some preview features we use, like `multiSchema` and `postgresqlExtensions` Add these to client block
## Introspect Database with the following command
```sh
bunx prisma db pull
```
This will update `schema.prisma` with all the tables as models
## Baseline the database
Create a directory to add migrations
```sh
mkdir -p prisma/migrations/0_init
```
Generate the migration diff
```sh
bunx prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > prisma/migrations/0_init/migration.sql
```
> [!warning]
> Modify the generated schema with the following github comment https://github.com/prisma/prisma/issues/17734#issuecomment-1452011006 as there is a bug in prisma
Finally Mark the migrations as applied with the following command
```sh
bunx prisma migrate resolve --applied 0_init
```
Update uuid extension by removing schema key
```
extensions = [uuid_ossp(map: "uuid-ossp")]
```