Skip to content

chienaeae/sql-testing-projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Testing Projects

Introduction

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.

Prerequisite

direnv

This project use a tool - direnv to load environment variables. Find more details, see the official website here.

docker

This project aims to containerized your testing database, and leverage docker to build and manage the container.

Setup

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"
...

Quick Start

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

Convenient commands

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published