Skip to content

Latest commit

 

History

History
75 lines (51 loc) · 1.48 KB

GUIDE_DATABASE.md

File metadata and controls

75 lines (51 loc) · 1.48 KB

Guide: Database

Follow this if want to run the database in a local container with Docker and Docker Compose.

Docker

Install and setup Docker on your system.

Docker Compose

Setup .env to contain these and change them as needed:

MYSQL_ROOT_PASSWORD=the_root_password
MYSQL_USER=the_user
MYSQL_PASSWORD=the_password
MYSQL_DATABASE=dogokit
MYSQL_HOST_PORT=3306
MYSQL_CONTAINER_PORT=3306

Start Docker service.

Run Docker Compose up.

docker-compose up

If everything is fine, exit and run it again in detached mode.

docker-compose up -d

Push the schema to it.

pnpm db:push

Seed initial data

pnpm db:seed

Note: Only need to push the schema in development. No need for migration files.

Database Backup and Restore with PlanetScale

Login with PlanetScale's pscale CLI:

pscale auth login

Dump to a backup:

# pscale db dump <database> <branch> --output <folder>
pscale db dump dogokit main --output dogokit-backup-mysql

Restore dump from the backup folder:

# pscale db restore-dump <database> <branch> --dir <folder>
pscale db restore-dump dogokit main --dir dogokit-backup-mysql