qrev

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2025 License: MIT Imports: 14 Imported by: 0

README

qrev

test Go Report Card

qrev is a SQL execution history management tool.

Installation

brew install winebarrel/qrev/qrev

Usage

Usage: qrev --dsn=STRING <command> [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 [<path>] [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 <status> <name> [flags]
    Manually mark the status of a SQL file (e.g., done, fail) in the history.

  plan --dsn=STRING [<path>] [flags]
    Show the list of SQL files that are planned to be executed.

  status --dsn=STRING [<status-or-filename>] [flags]
    Display the execution status of SQL files, optionally filtered by status or
    filename.

Run "qrev <command> --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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyCmd

type ApplyCmd struct {
	Path       string `arg:"" default:"*.sql" help:"Path of SQL files to run."`
	IfModified bool   `xor:"status" help:"Run if file has modified"`
	ForceRerun bool   `xor:"status" help:"Rerun any failed SQL files."`
}

func (*ApplyCmd) Run

func (cmd *ApplyCmd) Run(options *Options) error

type InitCmd

type InitCmd struct {
}

func (*InitCmd) Run

func (cmd *InitCmd) Run(options *Options) error

type MarkCmd

type MarkCmd struct {
	Status Status `arg:"" enum:"skip,fail" help:"Status to change."`
	Name   string `arg:"" required:"" help:"Filename in SQL history to mark."`
	Noop   bool   `short:"n" help:"No-op mode."`
}

func (*MarkCmd) Run

func (cmd *MarkCmd) Run(options *Options) error

type Options

type Options struct {
	DSN     string        `short:"d" required:"" env:"QREV_DSN" help:"DSN for the database to connect to."`
	Driver  driver.Driver `kong:"-"`
	Timeout time.Duration `env:"QREV_TIMEOUT" default:"3m" help:"Transaction timeout duration."`
	IAMAuth bool          `negatable:"" env:"QREV_IAM_AUTH" help:"Use RDS IAM authentication."`
	Color   bool          `negatable:"" env:"QREV_COLOR" short:"C" help:"Colorize output."`
	Output  io.Writer     `kong:"-"`
}

func (*Options) AfterApply

func (options *Options) AfterApply() error

func (*Options) BeforeApply

func (options *Options) BeforeApply() error

type PlanCmd

type PlanCmd struct {
	Path       string `arg:"" default:"*.sql" help:"Path of SQL files to run."`
	IfModified bool   `xor:"status" help:"Run if file has modified"`
	ForceRerun bool   `xor:"status" help:"Rerun any failed SQL files."`
}

func (*PlanCmd) Run

func (cmd *PlanCmd) Run(options *Options) error

type Status

type Status string
const (
	StatusDone Status = "done"
	StatusFail Status = "fail"
	StatusSkip Status = "skip"
)

func (Status) Color

func (status Status) Color() string

type StatusCmd

type StatusCmd struct {
	StatusOrFilename *string `arg:"" optional:"" help:"Status or Filename to filter."`
	ShowError        bool    `help:"Show last error message."`
	Count            uint64  `short:"n" help:"Number of output lines."`
}

func (*StatusCmd) Run

func (cmd *StatusCmd) Run(options *Options) error

Directories

Path Synopsis
cmd
qrev command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL