1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
class Bolt < Formula
desc "Lightweight and language-agnostic database migration tool"
homepage "https://git.sr.ht/~eugenetriguba/bolt"
url "https://git.sr.ht/~eugenetriguba/bolt/archive/37dd7b65846401ad34f449e0b2ad15a3b88aaec3.tar.gz"
version "0.12.0"
sha256 "eaf679593e03d618007a27f2e4d6f3950c6f667b8186fe3c61d7467c47a7da97"
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
assert_match "X", up_status_output
system bin/"bolt", "down"
down_status_output = shell_output("#{bin}/bolt status")
assert_match "20240101122412", down_status_output
assert_match "my_first_migration", down_status_output
refute_match "X", down_status_output
rm "migrations/20240101122412_my_first_migration.sql"
status_output = shell_output("#{bin}/bolt status")
refute_match "20240101122412", status_output
refute_match "my_first_migration", status_output
refute_match "X", status_output
end
end
|