Skip to content

Make database initialization safer #179

@milosmns

Description

@milosmns

Provide a brief summary of the planned work

Each service instance can run database migrations today. This should not be allowed, to prevent data duplication and corruption.

Detailed overview

Currently, any instance of the service can run database initialization. This is fine for a single-instance deployment, but once we raise two instances of the service, one will fail to take over the initialization or mess up the database.

Before migrating from Spring's JPA solution, we can implement improvements that allow only one instance to run the database migration. We can observe a simple RUN_MIGRATIONS environment variable/flag (or a more appropriate name) from the service.

When running in a multi-instance deployment setup, we can set this variable to false by default but set it to true for a single instance that will run the migration.

It's a naive solution, but it could bridge the gap before the database migration code is moved to a long-term/stable solution.

Hint/location:

[app.creator](application.yml:34)
com.appifyhub.monolith.features.init.domain.model.InitializationConfig
com.appifyhub.monolith.features.init.domain.SchemaInitializer

List the acceptance criteria

  • We can control which instances run the migrations and which don't
  • Service configuration files are updated to reflect these changes
  • Tests are written to reflect this change, and passing
  • Official instances at appifyhub.com are updated with the new configuration

Include any additional notes (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew functionality that didn't exist beforePlannedPlanned and roadmapped work

    Type

    No type

    Projects

    Status

    Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions