PostgreSQL Database

PostgreSQL Database Starter and Migration

Module Dependency

Add module dependency to your pom file.

<dependency>
    <groupId>org.archmix</groupId>
    <artifactId>legolas-postgresql</artifactId>
    <version>${legolasVersion}</version>
</dependency>

Starter

This module provides an PostgreSQL Starter as a managed container. The behavior may vary depends on the Runtime Environment you set.

Runtime Environment

Starter Behavior

LOCAL

A managed docker container will be created. The same container will be used for every execution, unless you destroy container by command line.

TEST

A managed docker container will be created and destroyed since test finishs.

SERVER

None container will be created or used.

Database Properties

Property

Value

Host

localhost

Port

5432

User

$(whoami)

Password

postgre

Database

$(whoami) lower case

User and Database properties

If your O.S. user name "$(whoami)" has any character out from A-Z a-z 0-9, so those chars will be replaced by underline (_) char. For instance, if the user name is "user.name" so the resulting value will be "user_name"

Running Instance Configuration

In order to get all the configurations through the code, you should do:

Migration

Migration will be running on every Runtime Environment unless you put no files in the target folder. The target folder is src/main/resources/services/postgre/migration. The file name should obey the following standard: V999_Description_of_what_this_file_do.sql. All the statements should be ended with ;

Example

Imagine you want to create a table called table_name with id and name columns. In order to do this you should create a file with the following path and name:

src/main/resources/services/postgre/migration/V001_Create_Table_Name.sql

Last updated

Was this helpful?