Skip to content

gullskatten/liquibase-tickets-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

liquibase-tickets-db

A sample Liquibase setup using liquibase-maven-plugin and PostgreSQL.

Covered in this example:

  • A liquibase-hierarchy example.
  • How to use .csv files to insert data into tables.
  • How to create tables, columns, and set restrictions (constraints).
  • How to add/update columns using changesets.
  • Simple rollback example.

Not covered:

  • Extract username/password from the POM configuration.
  • Creating indexes, triggers..

Hierarchy

The changelogs/master folder:

The master folder should contain all the 'databases'.

In this example we only work with one database, tickets.

The database-folder(s) (e.g. master/tickets):

A database-folder usually contain the following sub-folders:

  • data : All pre-defined data (inserted into the tables) will be included here.
  • testdata : All pre-defined test data. Keep data and test data separated!
  • tables : All the tables should be defined here.
  • indexes : All the create-index definitions should be defined here.

Additional examples..

  • packages : Any PL/SQL (e.g. in Oracle databases) should be defined here.
  • triggers : Any database triggers should be defined here.

Installation

1. Open postgresql (ex. through pgAdmin):

  • Create a tablespace named 'tickets_db'.
  • Create a database named 'tickets'. (This could be done using a sql-script, but I have not included this in the example).

2. Configure the liquibase-application.

Open the pom.xml, and change the configuration:

  • <url>jdbc:postgresql://localhost/tickets</url> : If you for some reason created a database with another name, change /tickets to your database name.
  • <username/> / <password/> : The username / password should not be configured here (in a real project).. :-)

3. Installation

Open a terminal window and run 'mvn clean install' in the projects root-folder - magic should now happen!

Releases

No releases published

Packages

No packages published