From 296c67c9f313a1e22cfee5a80b2fbd7554004570 Mon Sep 17 00:00:00 2001 From: Rubem Mota Date: Wed, 22 Mar 2023 22:17:41 +0000 Subject: [PATCH] feat(goose): Added aliases for goose migration tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rubem Mota --- plugins/goose/README.md | 24 ++++++++++++++++ plugins/goose/goose.plugin.zsh | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 plugins/goose/README.md create mode 100644 plugins/goose/goose.plugin.zsh diff --git a/plugins/goose/README.md b/plugins/goose/README.md new file mode 100644 index 000000000..8f6c7ae08 --- /dev/null +++ b/plugins/goose/README.md @@ -0,0 +1,24 @@ +# Goose plugin + +This plugin adds aliases for the [Goose](https://pressly.github.io/goose/) + +To use it, add `goose` to the plugins array in your zshrc file: + +```zsh +plugins=(... goose) +``` + +## Aliases + +| Alias | Command | Description | +| ------ | ----------------------------| -----------------------------------------------------------------| +| gmu | `goose up` | Apply all available migrations | +| gubo | `goose up-by-one` | Migrate up a single migration from the current version | +| gmd | `goose down` | Roll back a single migration from the current version | +| gmr | `goose redo` | Roll back the most recently applied migration, then run it again | +| gms | `goose status` | Print the status of all migrations: | +| gmcs | `goose create migration sql`| Create a new SQL migration | +| gmcg | `goose create migration go` | Create a new Go Migration | +| gmut | `goose up-to ` | Migrate up to a specific version` | +| gmdt | `goose down-to ` | Roll back migrations to a specific version. | +| gmf | `goose fix` | Apply sequential ordering to migrations | diff --git a/plugins/goose/goose.plugin.zsh b/plugins/goose/goose.plugin.zsh new file mode 100644 index 000000000..8fc35015a --- /dev/null +++ b/plugins/goose/goose.plugin.zsh @@ -0,0 +1,51 @@ +if (( ! $+commands[goose] )); then + echo "goose not found on Path" + return +fi + + +#========================# +# FUNCTIONS # +#========================# + +function gmcs() { + if [ -z "$1" ]; then + echo "Must specify migration name" + return + fi + goose create $1 sql +} + +function gmcg() { + if [ -z "$1" ]; then + echo "Must specify migration name" + return + fi + goose create $1 go +} + +function gmut() { + if [ -z "$1" ]; then + echo "Must specify migration version" + return + fi + goose up-to $1 +} + +function gmdt() { + if [ -z "$1" ]; then + echo "Must specify migration version" + return + fi + goose down-to $1 +} + +#========================# +# ALIAS # +#========================# +alias gmu="goose up" +alias gmubo="goose up-by-one" +alias gmd="goose down" +alias gmr="goose redo" +alias gms="goose status" +alias gmv="goose version"