~yerinalexey/gobin

c6e4af15a5c5b8494d48b5d3122a17bc9980b963 — Alexey Yerin 5 months ago 214d93c
gobin-migrate: wrap migrations in transaction
1 files changed, 8 insertions(+), 4 deletions(-)

M gobin-migrate
M gobin-migrate => gobin-migrate +8 -4
@@ 82,8 82,10 @@ apply_migration() {

  printf 'Applying migration %s\n' "$name"

  run_sql -f "$file" && \
    run_sql -c "insert into _gobin_migrations (name) values ('$name');" >/dev/null
  run_sql -c "begin;
$(cat "$file");
insert into _gobin_migrations (name) values ('$name');
commit;"
}

revert_migration() {


@@ 103,8 105,10 @@ revert_migration() {

  printf 'Reverting migration %s\n' "$name"

  run_sql -f "$file" && \
    run_sql -c "delete from _gobin_migrations where name='$name';" >/dev/null
  run_sql -c "begin;
$(cat "$file");
delete from _gobin_migrations where name='$name';
commit;"
}

up_migrations() {