This is a SQL Testing Environment for POC/Development/Prototyping scenarios. This project includes direnv settings and scripts to set up and connect to database. The (PG) database will run in a container. Therefore, it won't mess up your PC environment.
This project use a tool - direnv to load environment variables. Find more details, see the official website here.
This project aims to containerized your testing database, and leverage docker to build and manage the container.
To Set up Direnv Global env
block in .envrc
file
...
# Direnv Global env
# ==============
export DB_CONTAINER_NAME="udemy-course-pg-15"
export DB_CONTAINER_PORT="1111"
export DB_DEFAULT_DATABASE="udemy-course"
...
Run the containerized PostgreSQL
make postgresql
Create the default database
make createdb
Connect to the default database
make connect
Drop the default database
make dropdb
Connect to psql
psql-connect -d <database_name>
Execute sql file
psql-execute -d <database_name> -f <file_location>
Migrate database
# apply all the migrations
psql-migrate -d <database_name> up
# apply to the specific migrations
psql-migrate -d <database_name> goto <version>
# revert all the migrations
psql-migrate -d <database_name> down