Installation reminders
npm install <package>:pnpm add <package>npm install --save-dev <package>:pnpm add -D <package>
Cleaning up migrations
- Find the old .sql file(s) in
./drizzleand copy name(s) - In Terminal run
shasum -a 256 <file-path> - Remove the corresponding entry in
db/drizzle/__drizzle_migrations - Remove the .sql file(s)
- Remove the entries in
./drizzle/meta/_journal.json
Running Postgres with Docker locally
-
docker desktop start docker run --name my-postgres -e POSTGRES_USER=myuser -e POSTGRES_PASSWORD=mypassword -e POSTGRES_DB=mydb -p 5432:5432 -d postgres docker ps -a docker start my-postgres docker exec -it my-postgres bash psql -U myuser -d mydb- URL to connect to:
postgres://myuser:mypassword@localhost:5432/mydb --name my-postgres: Names the container-e POSTGRES_USER=myuser: Sets the database username-e POSTGRES_PASSWORD=mypassword: Sets the password-e POSTGRES_DB=mydb: Creates a database-p 5432:5432: Exposes PostgreSQL on port 5432-d postgres: Runs the official PostgreSQL image in the background
- URL to connect to:
-
Drop and recreate DB: log into separate database (
postgres) to modify/delete main database (mydb)-U: user-d: database name
psql -U myuser -d postgres
- Inside psql:
\l: view all databases\du: view all users- Note: don't drop
postgres,template0, ortemplate1databases - Sometimes might need to enter postgres db to delete other db:
\c postgres
DROP DATABASE your_database_name;
CREATE DATABASE your_database_name;
Running Redis with Docker locally
-
docker run -d --name redis-dev -p 6379:6379 redis docker ps -a -
Restart container/local database like local Postgres and Redis
docker container ls -a docker container start my-postgres docker container start redis-dev -
Close container
docker stop <container_id_or_name>