Comment on page
Seeding and migration
Data seeding or data migration involves adding data to ephemeral environments by running a process (either as a separate job or within your service) to populate the database with data that's usable.
Data seeding generally involves running a job alongside your services that connects to the database to create the appropriate contents. This could be as simple as running
mysql < seed.sql, or as complex as generating and injecting fake data.
You will need to develop a script that can be run within a job container (most frequently the same container as your service) that reads the appropriate environment variables for your database host, user, and password, and then connects and adds data.
There are standard frameworks for this in most languages.
Much like data seeding, data migration can be handled in a variety of ways, but it's commonly done within the framework you're writing software in (Django, Rails, etc.). Data migrations must be run at startup, so that the first thing your backend service does is run its own migrations into the empty database to populate it.
We commonly find that nobody has run migrations from scratch in years in the real world, and they often fail from empty databases if not exercised on a regular basis. You may have to do some repair work to make migrations work!