https://github.com/winebarrel/qrev
qrev is a SQL execution history management tool.
https://github.com/winebarrel/qrev
database golang mysql postgresql sqlite
Last synced: 12 days ago
JSON representation
qrev is a SQL execution history management tool.
- Host: GitHub
- URL: https://github.com/winebarrel/qrev
- Owner: winebarrel
- License: mit
- Created: 2025-10-11T00:51:57.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-12-28T13:12:43.000Z (30 days ago)
- Last Synced: 2025-12-29T22:50:19.065Z (28 days ago)
- Topics: database, golang, mysql, postgresql, sqlite
- Language: Go
- Homepage:
- Size: 149 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# qrev
[](https://github.com/winebarrel/qrev/actions/workflows/test.yml)
[](https://goreportcard.com/report/github.com/winebarrel/qrev)
qrev is a SQL execution history management tool.

## Installation
```sh
brew install winebarrel/qrev/qrev
```
## Usage
```
Usage: qrev --dsn=STRING [flags]
Flags:
-h, --help Show context-sensitive help.
-d, --dsn=STRING DSN for the database to connect to ($QREV_DSN).
--timeout=3m Transaction timeout duration ($QREV_TIMEOUT).
--[no-]iam-auth Use RDS IAM authentication ($QREV_IAM_AUTH).
-C, --[no-]color Colorize output ($QREV_COLOR).
--version
Commands:
apply --dsn=STRING [] [flags]
Apply SQL files to the database and record their execution history.
init --dsn=STRING [flags]
Initialize the SQL execution history table in the database.
mark --dsn=STRING [flags]
Manually mark the status of a SQL file (e.g., done, fail) in the history.
plan --dsn=STRING [] [flags]
Show the list of SQL files that are planned to be executed.
status --dsn=STRING [] [flags]
Display the execution status of SQL files, optionally filtered by status or
filename.
Run "qrev --help" for more information on a command.
```
```
$ echo 'SELECT 1' > 001.sql
$ echo 'SELECT now()' > 002.sql
$ echo 'SELECT CURRENT_DATE' > 003.sql
$ export QREV_DSN='file:test.db'
$ qrev init
qrev_history table has been created
$ qrev status
No SQL history
$ qrev plan
001.sql SELECT 1
002.sql SELECT now()
003.sql SELECT CURRENT_DATE
$ qrev apply
done 001.sql SELECT 1
fail 002.sql SELECT now()
│ SQL logic error: no such function: now (1)
qrev: error: SQL fails
$ qrev status --show-error
Oct 12 15:40 done a0a22c9 001.sql
Oct 12 15:40 fail df4776a 002.sql
│ SQL logic error: no such function: now (1)
$ qrev plan --if-modified
003.sql SELECT CURRENT_DATE
$ echo 'SELECT CURRENT_TIMESTAMP' > 002.sql
$ qrev plan --if-modified
002.sql* SELECT CURRENT_TIMESTAMP
003.sql SELECT CURRENT_DATE
$ qrev apply --if-modified
done 002.sql SELECT CURRENT_TIMESTAMP
done 003.sql SELECT CURRENT_DATE
$ qrev apply --if-modified
No SQL file to run
$ qrev status
Oct 12 15:40 done a0a22c9 001.sql
Oct 12 15:40 done 45fb14e 002.sql
Oct 12 15:40 done e8d881b 003.sql
```
### DSN
* MySQL: https://pkg.go.dev/github.com/go-sql-driver/mysql#readme-dsn-data-source-name
* PostgreSQL: https://pkg.go.dev/github.com/jackc/pgx/v5/stdlib#pkg-overview