feat(pakcage): migrator: add dependency
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
{ dash, hectic }:
|
{ dash, hectic, sqlite, postgresql_17 }:
|
||||||
let
|
let
|
||||||
shell = "${dash}/bin/dash";
|
shell = "${dash}/bin/dash";
|
||||||
bashOptions = [
|
bashOptions = [
|
||||||
@@ -9,7 +9,7 @@ let
|
|||||||
migrator = hectic.writeShellApplication {
|
migrator = hectic.writeShellApplication {
|
||||||
inherit shell bashOptions;
|
inherit shell bashOptions;
|
||||||
name = "migrator";
|
name = "migrator";
|
||||||
runtimeInputs = [ ];
|
runtimeInputs = [ sqlite postgresql_17 ];
|
||||||
|
|
||||||
text = ''
|
text = ''
|
||||||
${builtins.readFile hectic.helpers.posix-shell.log}
|
${builtins.readFile hectic.helpers.posix-shell.log}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ set -eu
|
|||||||
|
|
||||||
VERSION='0.0.1'
|
VERSION='0.0.1'
|
||||||
MIGRATION_DIR="${MIGRATION_DIR:-migration}"
|
MIGRATION_DIR="${MIGRATION_DIR:-migration}"
|
||||||
|
DB_URL="${DB_URL:-DB_URL}"
|
||||||
REMAINING_ARS=
|
REMAINING_ARS=
|
||||||
|
|
||||||
quote() { printf "'%s'" "$(printf %s "$1" | sed "s/'/'\\\\''/g")"; }
|
quote() { printf "'%s'" "$(printf %s "$1" | sed "s/'/'\\\\''/g")"; }
|
||||||
@@ -526,7 +527,6 @@ migrate_up() {
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# If "all" specified, migrate to the last migration
|
|
||||||
if [ "$apply_all" -eq 1 ]; then
|
if [ "$apply_all" -eq 1 ]; then
|
||||||
target_migration=$(printf '%s' "$fs_migrations" | tail -n1)
|
target_migration=$(printf '%s' "$fs_migrations" | tail -n1)
|
||||||
if [ -z "$target_migration" ]; then
|
if [ -z "$target_migration" ]; then
|
||||||
@@ -575,7 +575,6 @@ migrate_to() {
|
|||||||
|
|
||||||
[ "${migration_name+x}" ] || { log error "no migration name specified"; exit 1; }
|
[ "${migration_name+x}" ] || { log error "no migration name specified"; exit 1; }
|
||||||
|
|
||||||
# Handle special keywords for latest migration
|
|
||||||
case "$migration_name" in
|
case "$migration_name" in
|
||||||
latest|head|last)
|
latest|head|last)
|
||||||
# Return the last migration from filesystem
|
# Return the last migration from filesystem
|
||||||
@@ -914,7 +913,9 @@ fetch() {
|
|||||||
case $1 in
|
case $1 in
|
||||||
--db-url|-u)
|
--db-url|-u)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
DB_URL=$2
|
if ! [ "${DB_URL+x}" ]; then
|
||||||
|
DB_URL=$2
|
||||||
|
fi
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user