feat(rust): add a command to migrate a postgres database #8756
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a
migrate-postgres
command which can be used to check the migration status of a shared Postgres database and to migrate the current schema/data.Implementation notes
host_journey
tableI added the
host_journey
table to still be able to collect traces when there are command errors, even in contexts where a project does not exists.This allows to not change the existing code too much for the
migrate-postgres
command. Indeed that command might fail if theOCKAM_DATABASE_CONNECTION_URL
environment variable is not defined and in that case we create a command error user event.MigrationStatus
Most of the change consist in reporting richer data about the status of migrations, instead of simple booleans and errors.
Note that a failed migration is reported with an
Ok(status)
and RustErr
ors are left for infrastructure errors (broken connection for example).Version
I introduced a wrapper type,
Version
, aroundi64
for versions, to give that value its own meaning and make sure we don't make undue conversions.