0

I am new to liquibase. The 'backend' app runs locally with some basic changelog files.

I would like to get some test data from a server using pg_dump and pg_restore, and restore it to my local postgres DB.

How do I get that to work with liduibase? If that is not a good option, what would be a better option?

Annie C
  • 724
  • 2
  • 10
  • 30

2 Answers2

2

I found out a good way to export an entire database data into csv, is to use the below pg function, configure changelog to load the csv files, and map column headers if records have a lot of null data.

  1. Create one csv file per table: Export Database into CSV file
  2. Add changelog LoadData (the file path is relative to src/main/resources):

for example:

<changeSet author="programmer" id="mock_user_data">
    <loadData tableName="user_data" file="db/csv/public.user_data.csv" separator=";">  
        <column name="default_user" type="BOOLEAN"/>
        <column name="username" type="STRING"/>
        <column name="store_id" type="NUMERIC"/>                  
    </loadData>   </changeSet>
  1. If you get error messages caused by null values, look at your csv file, insert NULL in between delimiters, and make sure the problematic column name is mapped in the loadData section.
Community
  • 1
  • 1
Annie C
  • 724
  • 2
  • 10
  • 30
1

you could add a changelog to load data
Load data

you could possibly export from your DB as a csv and load with liquibase

austin
  • 1,143
  • 1
  • 12
  • 31