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?

2 Answers 2

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.
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.