Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust): add a command to migrate a postgres database #8756

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

etorreborre
Copy link
Member

@etorreborre etorreborre commented Jan 16, 2025

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 table

I 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 the OCKAM_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 Rust Errors are left for infrastructure errors (broken connection for example).

Version

I introduced a wrapper type, Version, around i64 for versions, to give that value its own meaning and make sure we don't make undue conversions.

@etorreborre etorreborre force-pushed the etorreborre/feat/migration-executable branch 2 times, most recently from c339ccc to 71e6622 Compare January 16, 2025 15:28
@etorreborre etorreborre marked this pull request as ready for review January 16, 2025 15:44
@etorreborre etorreborre requested a review from a team as a code owner January 16, 2025 15:44
@etorreborre etorreborre enabled auto-merge January 16, 2025 15:44
@etorreborre etorreborre force-pushed the etorreborre/feat/migration-executable branch 2 times, most recently from f4659bb to 41e06ce Compare January 17, 2025 12:56
@etorreborre etorreborre self-assigned this Jan 17, 2025
| Conflicts:
|	implementations/rust/ockam/ockam_command/src/lib.rs
|	implementations/rust/ockam/ockam_command/src/subcommand.rs

| Conflicts:
|	implementations/rust/ockam/ockam_command/src/lib.rs
|	implementations/rust/ockam/ockam_command/src/subcommand.rs
@etorreborre etorreborre force-pushed the etorreborre/feat/migration-executable branch from 6e491da to 8523dd6 Compare January 20, 2025 18:33
@adrianbenavides adrianbenavides self-requested a review January 21, 2025 08:14
@etorreborre etorreborre added this pull request to the merge queue Jan 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 21, 2025
@etorreborre etorreborre added this pull request to the merge queue Jan 21, 2025
Merged via the queue into develop with commit 7560ee1 Jan 21, 2025
44 checks passed
@etorreborre etorreborre deleted the etorreborre/feat/migration-executable branch January 21, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants