Hi everyone ,
Here is a quick example of how to seed a Postgres database with a simple SQL and Shell script using a Qovery Lifecycle Job.
Extracted from the README. Here are the instructions:
Seed your Postgres database with a SQL script
This example shows you how to seed your Postgres database with a SQL script.
- Our SQL Script downloads from a S3 bucket to avoid storing sensitive data in this repository. This is a good practice to follow.
- You can remove the S3 download part to put a SQL script in this repository. However, it’s not recommended to store sensitive data in a public
How to use
- Fork this repository
- Create a Lifecycle Job
- Select your forked repository with the appropriate branch (e.g.
- Set the “Root application path” to the example you want to use (e.g.
- Set the “Dockerfile path” to the Dockerfile in the example you want to use (e.g.
- Select “Start” event and add the following CMD Arguments:
["-c", "seed.sh"]- which indicates to the Lifecycle Job to run the
seed.shscript when the Lifecycle Job starts.
- Create your Lifecycle Job but do not deploy it yet.
- Go to your Lifecycle Job variables and create:
DATABASE_URLenvironment variable alias to provide to
seed.shyour database connection string where to restore your seed.
SEED_URLenvironment variable alias to provide to
seed.shyour seed SQL script URL. (can be a public S3 bucket URL or any other URL)
- Deploy your Lifecycle Job.
Your database is now seeded with your SQL script.
I’ll complete this thread with a demo video in the coming days