1

Is there a best practice for initializing and managing database schema(and seed data) for containerized backend applications?

I'm currently developing an on-premise application deployed at the customer's server(either Kubernetes cluster or docker-compose environment). After the database container starts, we manually run the Kubernetes job that generates database schema and seeds initial administrator account data. I want to automate the process. Running migration and seeding for every deployment makes me tired.

Here is another problem. After the schema change, I have to migrate the database schema. In this case, we have to check which seeding scripts ran, then execute the scripts which never ran.

Is there any best practice for managing database schema for containerized, on-premise applications? And can it be automated?

1
  • database or any stateful data: when your application container starts, it should check for existing data, apply upgrade scripts if needed, init a new database if nothing was found, ... And while those steps should run by defaults starting your main container: for larger datasets it would make sense to relocate those scripts into an initContainer.
    – SYN
    Oct 16, 2022 at 18:49

0

Your Answer

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