From faa3291e59d7fa3ba54c5c9e55bb828173e030dc Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 23 Mar 2024 07:23:41 -0400 Subject: Initial commit --- Formula/bolt.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Formula/bolt.rb (limited to 'Formula') diff --git a/Formula/bolt.rb b/Formula/bolt.rb new file mode 100644 index 0000000..7748511 --- /dev/null +++ b/Formula/bolt.rb @@ -0,0 +1,35 @@ +class Bolt < Formula + desc "Lightweight and language-agnostic database migration tool" + homepage "https://github.com/eugenetriguba/bolt" + url "https://github.com/eugenetriguba/bolt/archive/refs/tags/v0.8.0.tar.gz" + sha256 "7f1f8b3f20ed224f9f1b7d8c6dc56b726b0edb5cf60528de534f11377c5d80b9" + license "MIT" + + depends_on "go" => :build + + def install + system "go", "build", *std_go_args(ldflags: "-s -w"), "-o", bin/"bolt", "cmd/bolt/bolt.go" + end + + test do + ENV["BOLT_DB_NAME"] = "test.db" + ENV["BOLT_DB_DRIVER"] = "sqlite3" + mkdir "migrations" + (testpath/"migrations"/"20240101122412_my_first_migration.sql").write <<~EOS + -- migrate:up + CREATE TABLE users(id INT PRIMARY KEY); + -- migrate:down + DROP TABLE users; + EOS + + system bin/"bolt", "up" + up_status_output = shell_output("#{bin}/bolt status") + assert_match "20240101122412", up_status_output + assert_match "my_first_migration", up_status_output + system bin/"bolt", "down" + down_status_output = shell_output("#{bin}/bolt status") + refute_match "20240101122412", up_status_output + refute_match "my_first_migration", up_status_output + end +end + -- cgit v1.2.3