Skip to content

doraemoncito/postgresql-container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostgreSQL database with embedded schema migrator

Docker image containing a PostgreSQL database and a schema migrator to simplify database schema upgrades.

Building the Docker image

Using the Maven command line:

mvn clean install

Using the Docker command line:

From the top-level directory, run the following command to copy the build assets to the target directory:

mvn compile

Then go to the target directory and invoke Docker build as shown here:

pushd target/docker
docker build . --tag localhost.localdomain/postgresql-container:latest --no-cache    
popd

Running the database

Use the following command to the start the Database in a background docker container:

docker run -p 5432:5432 --name postgres -d localhost.localdomain/postgresql-container:latest

Connecting to the database

Use the following JDBC URL to connect to the database:

jdbc:postgresql://localhost:5432/postgres

Extending the database schema

To extend the schema definition with the tables, data, etc, simply add new idempotent SQL scripts to the src/main/resources/db/migration/ folder.

The SQL script file names must follow the pattern SPRINT<zero padded three digit sprint number>_<zero padded two digit script order number>__<description>.sql as shown in this example: SPRINT001_01__Initial_database_revision.sql.

Resources

About

Containerised PostgreSQL database with flyway baked-in

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published