Bieber 296bccd7bc
[sync] fix: canery header in ai T2247 (#1361) (#2701)
Synced from teableio/teable-ee@490e381

Co-Authored-By: Pengap <penganpingprivte@gmail.com>
Co-Authored-By: Boris <boris2code@outlook.com>
Co-Authored-By: Sky-FE <sky.huang.fe@gmail.com>
Co-Authored-By: younocode <tianyangchen1@gmail.com>
Co-Authored-By: garyli27 <guangyu.li727@gmail.com>
Co-Authored-By: HynLcc <hynlcc@gmail.com>
2026-03-06 12:01:01 +08:00
..
2024-10-23 15:24:49 +08:00
2025-10-17 18:08:18 +08:00
2024-01-30 22:20:05 +08:00
2025-02-06 14:42:47 +08:00
2024-01-30 22:20:05 +08:00
2024-01-30 22:20:05 +08:00

@teable/db-main-prisma

build

Intro

Basic demo of a shared package using prisma to handle database access, part of the nextjs-monorepo-example

Quick start

Start the database with docker-compose up database then run

cd packages/db-main-prisma
yarn prisma-db-push

See the .env(.local|.production|.development) file to edit the connection. Curious about the setup ?, we use dotenv-flow under the hood read this and see the script section of ./package.json

Install

Database

Option 0: sqlite local

The default env for PRISMA_DATABASE_URL is defined in the main .env file. By default, it connects to the sqlite file main.db

Option 1: Postgresql local (deprecated)

The default env for PRISMA_DATABASE_URL is defined in the main .env file. By default, it connects to the postgresql service defined in ../../docker-compose.yml.

Ensure you have docker and docker-compose and run

# In the root folder
docker-compose up database
# Alternatively, from any folder
yarn docker:up

Option 2: An hosted postgres instance (deprecated)

To quick start, you can use a free tier at supabase.io, but all providers will work.

As an example, simply create an .env.local and set the supabase pgbouncer url:

PRISMA_DATABASE_URL=postgresql://postgres:[PASSWORD]@[HOST]:[PORT]/postgres?schema=public&pgbouncer=true&sslmode=require&sslaccept=strict&sslcert=../config/certs/supabase-prod-ca-2021.crt

You can append &connection_limit=1 if deploying on a serverless/lambda provider (ie: vercel, netlify...)

DB creation

To create the database, simply run

yarn prisma-db-push

DB type generation

Create or update the types. This is generally automatically done in a postinstall from any app, see script section of ../../apps/nextjs-app/package.json or try it out with yarn workspace web-app postinstall

yarn prisma generate