-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: add hsdev
binary to run migrations
#4877
Conversation
crates/hsdev/src/tests/mod.rs
Outdated
let toml_str = "username = \"db_user\"\n\ | ||
password = \"db_pass\"\n\ | ||
dbname = \"db_name\"\n\ | ||
host = \"localhost\"\n\ | ||
port = 5432"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional change: you can take advantage of Rust's raw string literals instead of having to escape quotes:
let toml_str = r#"username = "db_user"
password = "db_pass"
dbname = "db_name"
host = "localhost"
port = 5432"#;
@davidkurilla @JamesM25 Could you also address the failing CI checks? |
@JamesM25 Please address the |
hsdev
binary to run migrations
hsdev
binary to run migrationshsdev
binary to run migrations
Type of Change
Description
This PR closes #4589
Created a new Rust binary in the
crates
directory which automates the Diesel migrations with Postgres. The new tool is a CLI tool that takes a path to a TOML file as an argument along with the name of a TOML table to extract Postgres database credentials from. The tool then automatically performs the migrations by utilizingdiesel_migrations
library. From our testing, we were able to set up Hyperswitch locally without usingdiesel_cli
and Bash variables on WSL2 Ubuntu.I worked on this Issue with @JamesM25 @ind1goDusk
The example below shows the application running using
cargo run
in thehsdev
crate.cargo run -- --toml-file ~/hyperswitch/config/development.toml --toml-table master_database
Additional Changes
Motivation and Context
Before our tool, Hyperswitch needed to be set up on local machines using a long
diesel_cli
command with Bash variables for the Postgres migration. Now we have provided a simpler and easily repeatable solution to Postgres and Diesel migrations that allows for greater modularity as you can select specific TOML files and tables to select database credentials from.How did you test it?
We wrote two units test on the core functionality. We tested it both on a dummy TOML file as well as in Hyperswitch repository. We were able to set up Hyperswitch locally using
hsdev
instead ofdiesel_cli
.Checklist
cargo +nightly fmt --all
cargo clippy