Crates.io | dry_sql |
lib.rs | dry_sql |
version | 0.1.4 |
source | src |
created_at | 2024-04-27 22:51:32.136244 |
updated_at | 2024-05-09 08:12:54.000431 |
description | CLI tool to dry-run your SQL scripts |
homepage | |
repository | |
max_upload_size | |
id | 1222894 |
size | 37,941 |
CLI tool to dry run your SQL scripts
This tool was created when I was setting up some database migrations stuffs in the CI pipeline that was supposed to be executed on another environment. The migration should be applied on main branch. It's mandatory that specific migrations in a the pull request get successfully applied before the app is deployed.
If the team practices DB migrations strictly, then the presence of migration issues would be minimalized or nihilized. However,developers are human after all. Some migrations scripts some times failed to execute due to some human errors. Hence, there is a need to validate the migration scripts which are SQL scripts without committing them.
While some SQL script linter have benefits to check for SQL statement for errors, they don't validate whether your scripts would be successfully executed. There are several reasons why a SQL script might fail to execute even if it passes the linter:
The most common use case would be obviously to validate migration SQL scripts in the pipeline :). Of course, you can use it to mimick your SQL scripts anywhere else.
On the terminal:
if you want to dry-run a SQL file.
dry_sql --host <host> --port <port> --user <username> --password <password> --file <path/to/your/sql/script>
if you want to dry-run multiple a SQL inside a folder.
dry_sql --host <host> --port <port> --user <username> --password <password> --dir <path/to/your/sql/script/foder>
Currently, this tool only support Postgres SQL. The rest will be coming along.
Written in Rust.