Vercel/PostgreSQL to Local Migration: Next.js Dashboard App
I have migrated the database of the Next.js Dashboard App from Vercel/PostgreSQL (referred to as Postgres) to a local setup. You can find the code differences (opens in a new tab) on GitHub. The actual code changes required for the migration are contained within the following four files:
- seed.js
- actions.ts
- data.ts
- auth.th
- db.ts
Migration
Installing PostgreSQL Locally
The process of installing PostgreSQL locally will be explained on a separate page later.
Updating the .env File
Instructions for updating the .env file will be provided on a separate page later.
Installing the pg Package in the Project
Install the node-postgres (opens in a new tab) package (abbreviated as pg), which is a collection of Node.js modules for interfacing with your PostgreSQL database. For local PostgreSQL, we use the pg package, while for Vercel/Postgres, the @Vercel/Postgres package is utilized.
This installation process will update the package-lock.json
and package.jason
files. Use the following command:
npm install pg
Code Changes
For more detailed information, please refer to the code differences (opens in a new tab) on GitHub.