File tree Expand file tree Collapse file tree 5 files changed +32
-7
lines changed
Expand file tree Collapse file tree 5 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -105,14 +105,19 @@ Or install manually via the [pgvector guide](https://github.com/pgvector/pgvecto
105105
106106``` bash
107107cp apps/sim/.env.example apps/sim/.env
108+ # Create your secrets
109+ perl -i -pe " s/your_encryption_key/$( openssl rand -hex 32) /" apps/sim/.env
110+ perl -i -pe " s/your_internal_api_secret/$( openssl rand -hex 32) /" apps/sim/.env
111+ perl -i -pe " s/your_api_encryption_key/$( openssl rand -hex 32) /" apps/sim/.env
112+ # DB configs for migration
108113cp packages/db/.env.example packages/db/.env
109114# Edit both .env files to set DATABASE_URL="postgresql://postgres:your_password@localhost:5432/simstudio"
110115```
111116
1121174 . Run migrations:
113118
114119``` bash
115- cd packages/db && bunx drizzle-kit migrate --config=./drizzle.config.ts
120+ cd packages/db && bun run db: migrate
116121```
117122
1181235 . Start development servers:
Original file line number Diff line number Diff line change 11# Database (Required)
2- DATABASE_URL = " postgresql://postgres:password@localhost:5432/postgres"
3-
4- # PostgreSQL Port (Optional) - defaults to 5432 if not specified
5- # POSTGRES_PORT=5432
2+ DATABASE_URL = " postgresql://postgres:your_password@localhost:5432/simstudio"
63
74# Authentication (Required unless DISABLE_AUTH=true)
85BETTER_AUTH_SECRET = your_secret_key # Use `openssl rand -hex 32` to generate, or visit https://www.better-auth.com/docs/installation
Original file line number Diff line number Diff line change 11# Database URL (Required for migrations and database operations)
2- DATABASE_URL = " postgresql://postgres:password @localhost:5432/simstudio"
2+ DATABASE_URL = " postgresql://postgres:your_password @localhost:5432/simstudio"
Original file line number Diff line number Diff line change 2020 },
2121 "scripts" : {
2222 "db:push" : " bunx drizzle-kit push --config=./drizzle.config.ts" ,
23- "db:migrate" : " bun --env-file=.env --bun x drizzle-kit migrate --config=./drizzle.config .ts" ,
23+ "db:migrate" : " bun --env-file=.env run ./scripts/migrate .ts" ,
2424 "db:studio" : " bunx drizzle-kit studio --config=./drizzle.config.ts" ,
2525 "type-check" : " tsc --noEmit" ,
2626 "lint" : " biome check --write --unsafe ." ,
Original file line number Diff line number Diff line change 1+ import { drizzle } from 'drizzle-orm/postgres-js'
2+ import { migrate } from 'drizzle-orm/postgres-js/migrator'
3+ import postgres from 'postgres'
4+
5+ const url = process . env . DATABASE_URL
6+ if ( ! url ) {
7+ console . error ( 'ERROR: Missing DATABASE_URL environment variable.' )
8+ console . error ( 'Ensure packages/db/.env is configured.' )
9+ process . exit ( 1 )
10+ }
11+
12+ const client = postgres ( url , { max : 1 , connect_timeout : 10 } )
13+
14+ try {
15+ await migrate ( drizzle ( client ) , { migrationsFolder : './migrations' } )
16+ console . log ( 'Migrations applied successfully.' )
17+ } catch ( error ) {
18+ console . error ( 'ERROR: Migration failed.' )
19+ console . error ( error instanceof Error ? error . message : error )
20+ process . exit ( 1 )
21+ } finally {
22+ await client . end ( )
23+ }
You can’t perform that action at this time.
0 commit comments