Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update the PlanetScale local development docs

Zach Waterfield51fdf55f202c
diff --git a/apps/docs/local-development.mdx b/apps/docs/local-development.mdx
index 205c2b1e8d..086f123aa9 100644
--- a/apps/docs/local-development.mdx
+++ b/apps/docs/local-development.mdx
@@ -216,7 +216,11 @@ Navigate to the [QStash tab](https://console.upstash.com/qstash) and copy the `Q
### Step 4: Set up Planetscale database
-Next, you'll need to set up the Planetscale MySQL database:
+Next, you'll need to set up the MySQL database that is compatible with Planetscale. This will be used to store user data and link metadata. There are two options:
+
+**Option 1: PlanetScale hosted database**
+
+You can use a PlanetScale hosted database. Note they've removed the free tier, so you'll need to pay for this option.
<Steps>
@@ -256,6 +260,56 @@ Next, you'll need to set up the Planetscale MySQL database:
</Steps>
+**Option 2: Local MySQL database with PlanetScale simulator**
+
+You can use a local MySQL database with a PlanetScale simulator. This is the recommended option for local development.
+
+Prerequisites:
+- [Docker](https://www.docker.com/products/docker-desktop)
+- [Docker Compose](https://docs.docker.com/compose/install/)
+
+<Steps>
+
+ <Step title="Spin up the docker-compose stack">
+
+ In the terminal, navigate to the `apps/web` directory and run the following command to start the Docker Compose stack:
+
+ ```bash Terminal
+ docker-compose up
+ ```
+
+ This will start two containers: one for the MySQL database and another for the PlanetScale simulator.
+ </Step>
+
+ <Step title="Set up database environment variables">
+
+ **Add credentials to .env** section.
+
+ ```
+ PLANETSCALE_DATABASE_URL="http://root:unused@localhost:3900"
+ DATABASE_URL="mysql://root:@localhost:3306/planetscale"
+ ```
+
+ </Step>
+
+ <Step title="Generate Prisma client and create database tables">
+
+ In the terminal, navigate to the `apps/web` directory and run the following command to generate the Prisma client:
+
+ ```bash Terminal
+ npx prisma generate
+ ```
+
+ Then, create the database tables with the following command:
+
+ ```bash Terminal
+ npx prisma db push
+ ```
+
+ </Step>
+
+</Steps>
+
### Step 5: Set up GitHub OAuth
Next, follow [these steps](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps) to create a GitHub App. This will allow you to sign in to Dub.co with your GitHub account.
diff --git a/apps/web/.env.example b/apps/web/.env.example
index 23ed8dc924..c1326f41be 100644
--- a/apps/web/.env.example
+++ b/apps/web/.env.example
@@ -31,6 +31,8 @@ QSTASH_NEXT_SIGNING_KEY=
# MySQL Database via Planetscale
# Get your MySQL Database URL here: https://planetscale.com/docs/tutorials/connect-nodejs-app
+# Set local development documentation for connecting to a local database: https://dub.co/docs/local-development#step-4-set-up-planetscale-database
+PLANET_SCALE_DATABASE_URL=
DATABASE_URL=
# Generate a random secret here: https://generate-secret.vercel.app/32