Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refractor Planetscale to Neon #234

Merged
merged 11 commits into from
May 11, 2024
Prev Previous commit
Next Next commit
fix runtime error with cannot find DB
  • Loading branch information
shouryan01 committed Apr 27, 2024
commit eb7c63c091f60804916ec5ff7d4847b2f468d86b
7 changes: 2 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL="/dashboard"
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL="/dashboard"

# -----------------------------------------------------------------------------
# Database (MySQL - PlanetScale)
# Database (Neon - PostgreSQL)
# -----------------------------------------------------------------------------
DATABASE_USERNAME=
DATABASE_PASSWORD=pscale_pw_
DATABASE_HOST=eu-west.connect.psdb.
DATABASE_NAME=YOUR_DB_NAME
NEXT_PUBLIC_DATABASE_URL=

# -----------------------------------------------------------------------------
# Stripe
Expand Down
2 changes: 2 additions & 0 deletions apps/www/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const env = createEnv({
NEXT_PUBLIC_STRIPE_STD_MONTHLY_PRICE_ID: z.string().min(1).optional(),
NEXT_PUBLIC_STRIPE_PRO_PRODUCT_ID: z.string().min(1).optional(),
NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PRICE_ID: z.string().min(1).optional(),
NEXT_PUBLIC_DATABASE_URL: z.string().url(),
},
/**
* Destructure all variables from `process.env` to make sure they aren't tree-shaken away.
Expand All @@ -45,6 +46,7 @@ export const env = createEnv({
process.env.NEXT_PUBLIC_STRIPE_PRO_PRODUCT_ID,
NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PRICE_ID:
process.env.NEXT_PUBLIC_STRIPE_PRO_MONTHLY_PRICE_ID,
NEXT_PUBLIC_DATABASE_URL: process.env.NEXT_PUBLIC_DATABASE_URL,
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation.
Expand Down
5 changes: 3 additions & 2 deletions packages/db/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export * from "./enum";

export * from "drizzle-orm";

//TODO FIX: This is a temporary solution to avoid runtime error with cannot find DB.
import { env } from "../../../apps/www/env";

export const db = drizzle(
neon(process.env.DATABASE_URL || "PASTE INN YOUR DATABASE URL HERE"),
neon(env.NEXT_PUBLIC_DATABASE_URL!),
);

// Use custom alphabet without special chars for less chaotic, copy-able URLs
Expand Down