-
Hello community! I've been using drizzle with PlanetScale and it's been working wonderful. I wanted to ask, how do you develop using a local mysql and then use PlanetScale for production? I'm using cloudflare workers which has some extra limitations running locally in workerd with their latest wrangler version. Using PS for development is not ideal with my spotty internet, has someone figured out how to swap from local mysql to PS? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
You don't , your dev env is also on PS (just another "dev" branch). So, in dev you just have another connection string than on production. Much easier to setup. The actual workflow is (1) branch from production on PS, (2) work and change on dev, (3) push changes (called "deploy request" on PS) to production. |
Beta Was this translation helpful? Give feedback.
-
Planetscale provides you free tier, as long as you don't blow up your dev env then it's fine, we don't need a local db |
Beta Was this translation helpful? Give feedback.
-
You should have two instance and inject those depending on your environment, for instance, for running with a planet scale instance you would use this import { connect } from '@planetscale/database'
import { drizzle } from 'drizzle-orm/planetscale-serverless'
export function createDB() {
const connection = connect({ url: env.DATABASE_URL })
const db = drizzle(connection)
return db
} And when running locally with your local MySQL DB you would use this instead import { drizzle } from 'drizzle-orm/mysql2'
import mysql from 'mysql2/promise'
export function createLocalDB() {
const poolConnection = mysql.createPool({ uri: env.LOCAL_DATABASE_URL })
const db = drizzle(poolConnection)
return db
} Personally I have two start scripts, |
Beta Was this translation helpful? Give feedback.
You don't , your dev env is also on PS (just another "dev" branch). So, in dev you just have another connection string than on production. Much easier to setup.
The actual workflow is (1) branch from production on PS, (2) work and change on dev, (3) push changes (called "deploy request" on PS) to production.