Search code examples
javapostgresqlintegration-testingjboss-arquillianpostgresql-initdb

How to create a temporary database with postgresql initdb?


How do I create a temporary database for PostgreSQL using initdb? Also, how do I populate it with dummy data and how do I delete it after usage?

I have an entire schema of the database. I don't want to create temporary tables one by one. Using initdb, I would like to be able to give the schema and get a database with the tables, etcetera created.

This is for running integration tests of a spring boot application. I use mybatis to access the database.

Can I use any other tool like arquillian?


Solution

  • There's a workaround this, just change the data directory to a RAM file system, like this once you restart your computer, the data is gone. better you won't change anything in your scripts.