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.
Important
- 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
repository.
How to use
- Fork this repository
- Create a Lifecycle Job
- Select your forked repository with the appropriate branch (e.g.
main
) - Set the “Root application path” to the example you want to use (e.g.
examples/seed-postgres-database-with-sql-script
) - Set the “Dockerfile path” to the Dockerfile in the example you want to use (e.g.
Dockerfile
) - Select “Start” event and add the following CMD Arguments:
["-c", "seed.sh"]
- which indicates to the Lifecycle Job to run theseed.sh
script when the Lifecycle Job starts. - Create your Lifecycle Job but do not deploy it yet.
- Go to your Lifecycle Job variables and create:
DATABASE_URL
environment variable alias to provide toseed.sh
your database connection string where to restore your seed.SEED_URL
environment variable alias to provide toseed.sh
your 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