-
Notifications
You must be signed in to change notification settings - Fork 29
CI: Codify migrations procedure #1022
Description
From time to time, data formats for Deliberate Lab may change. In such cases, existing documents in the Firestore database may need to be bulk migrated to a new format. For example, #939 introduces a functions/src/migrations/migrate-variable-configs.ts file, which converts variable configurations from an older to newer format.
Managing schema migrations such as this is not a new problem. SQL table schemas have the same problem.
We should investigate industry best practices for migrating documents in document datastores like Firebase so that we can choose a strategy for handling these going forward. We should aim to serve both the canonical Deliberate Lab installation as well as third parties running their own instances.
Two concerns are top of mind:
- Running hermetic migrations: Building and running migration scripts in a hermetic environment such as Google Cloud Build. This avoids problems of local development setup, which may be in a bad state.
- Automatically running migrations: Detecting whether migrations have run, and if not, running them exactly once. This could be rolled into the canonical Google Cloud Build pipeline so that running an "all" deployment automatically performs migrations.