backhoe 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/Appraisals +6 -6
- data/CLAUDE.md +36 -0
- data/backhoe.gemspec +1 -0
- data/gemfiles/{activerecord_7.0.gemfile → activerecord_8.0.gemfile} +1 -1
- data/gemfiles/{activerecord_7.1.gemfile → activerecord_8.1.gemfile} +1 -1
- data/lib/backhoe/database.rb +9 -0
- data/lib/backhoe/dump.rb +2 -0
- data/lib/backhoe/load.rb +8 -3
- data/lib/backhoe/version.rb +1 -1
- metadata +20 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: abfe37e5c43ef24a835955e044c32bef198a37d007372ec45a9ade0a6ea76b67
|
|
4
|
+
data.tar.gz: 451090a75bf1b09d2c22f6e8b4a952a2c7fa531e6b11f49e0f3ffcb3d32fbad9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8be5bb5fdc1dab88f907b60a36e168d6ee0b613ab135e2b2e4b7dad7fab89cbaae2df8dd0422879f7f3a0b3d4f7d9d6f8d1f17d5a5e1b1671d9c3c627b3fc045
|
|
7
|
+
data.tar.gz: d8b73ba874184015ff2fc59a79fb011b25b4b0ba7773938cb169fd3da5373e8701f36f62b5477f84dbd188c29a2daa29cc06a64d1f8fb2e575dcc6ffa35820d6
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -5,8 +5,8 @@ jobs:
|
|
|
5
5
|
strategy:
|
|
6
6
|
fail-fast: false
|
|
7
7
|
matrix:
|
|
8
|
-
gemfile: [ activerecord_7.
|
|
9
|
-
ruby: [ 3.
|
|
8
|
+
gemfile: [ activerecord_7.2, activerecord_8.0, activerecord_8.1 ]
|
|
9
|
+
ruby: [ 3.3, 3.4, "4.0" ]
|
|
10
10
|
|
|
11
11
|
runs-on: ubuntu-22.04
|
|
12
12
|
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
data/Appraisals
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
appraise "activerecord-7.
|
|
2
|
-
gem "activerecord", "~>7.
|
|
1
|
+
appraise "activerecord-7.2" do
|
|
2
|
+
gem "activerecord", "~>7.2.0"
|
|
3
3
|
end
|
|
4
4
|
|
|
5
|
-
appraise "activerecord-
|
|
6
|
-
gem "activerecord", "~>
|
|
5
|
+
appraise "activerecord-8.0" do
|
|
6
|
+
gem "activerecord", "~>8.0.0"
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
appraise "activerecord-
|
|
10
|
-
gem "activerecord", "~>
|
|
9
|
+
appraise "activerecord-8.1" do
|
|
10
|
+
gem "activerecord", "~>8.1.0"
|
|
11
11
|
end
|
|
12
12
|
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project
|
|
6
|
+
|
|
7
|
+
Backhoe is a Ruby gem for dumping and loading ActiveRecord database contents to/from files. Supports MySQL, PostgreSQL, and SQLite adapters with gzip compression and remote HTTP PUT.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bundle exec rake # Run full test suite (RSpec)
|
|
13
|
+
bundle exec rspec # Run all specs
|
|
14
|
+
bundle exec rspec spec/backhoe/dump_spec.rb # Run a single spec file
|
|
15
|
+
bundle exec rspec spec/backhoe/dump_spec.rb:15 # Run a single example by line
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Tests require running MySQL and PostgreSQL services. Test database config is in `spec/support/database.yml`.
|
|
19
|
+
|
|
20
|
+
## Architecture
|
|
21
|
+
|
|
22
|
+
The gem has two public methods: `Backhoe.dump(path, **options)` and `Backhoe.load(path, **options)`.
|
|
23
|
+
|
|
24
|
+
Three core classes implement the functionality:
|
|
25
|
+
|
|
26
|
+
- **Backhoe::Database** (`lib/backhoe/database.rb`) - Reads ActiveRecord connection config, detects the adapter type (`mysql?`, `postgresql?`, `sqlite?`), and builds CLI options for database tools.
|
|
27
|
+
- **Backhoe::Dump** (`lib/backhoe/dump.rb`) - Runs `mysqldump`, `pg_dump`, or file copy depending on adapter. Handles gzip, table skipping, column sanitization (via temp tables), and HTTP PUT for remote storage. Uses `Rake::DSL#sh` for shell commands.
|
|
28
|
+
- **Backhoe::Load** (`lib/backhoe/load.rb`) - Runs `mysql`, `psql`, or file copy to restore. Supports gzip decompression and optional drop/create database.
|
|
29
|
+
|
|
30
|
+
Shell commands use `set -o pipefail` in bash to catch piping errors.
|
|
31
|
+
|
|
32
|
+
## Testing
|
|
33
|
+
|
|
34
|
+
The test suite uses Appraisals to test against ActiveRecord 7.0, 7.1, and 7.2. CI runs on GitHub Actions across Ruby 3.1–3.3 with that matrix.
|
|
35
|
+
|
|
36
|
+
Test support files in `spec/support/` include a `Database` helper class for creating/destroying test databases and fixture SQL files for both MySQL and PostgreSQL.
|
data/backhoe.gemspec
CHANGED
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.add_development_dependency "appraisal"
|
|
29
29
|
spec.add_development_dependency "mysql2"
|
|
30
30
|
spec.add_development_dependency "pg"
|
|
31
|
+
spec.add_development_dependency "sqlite3"
|
|
31
32
|
spec.add_development_dependency "byebug"
|
|
32
33
|
spec.add_development_dependency "timecop"
|
|
33
34
|
spec.add_development_dependency "webrick"
|
data/lib/backhoe/database.rb
CHANGED
data/lib/backhoe/dump.rb
CHANGED
|
@@ -32,6 +32,8 @@ module Backhoe
|
|
|
32
32
|
bash_sh "#{mysqldump} --no-create-db --single-transaction --quick -e #{skip_table_options} #{database.to_mysql_options} #{database.name} | #{pipe} #{target}"
|
|
33
33
|
elsif database.postgresql?
|
|
34
34
|
bash_sh "#{pg_dump} --column-inserts #{database.name} | #{pipe} #{target}"
|
|
35
|
+
elsif database.sqlite?
|
|
36
|
+
bash_sh "cat #{database.path} | #{pipe} #{target}"
|
|
35
37
|
else
|
|
36
38
|
raise "don't know how to dump #{database.adapter}"
|
|
37
39
|
end
|
data/lib/backhoe/load.rb
CHANGED
|
@@ -5,11 +5,12 @@ module Backhoe
|
|
|
5
5
|
include Rake::DSL
|
|
6
6
|
|
|
7
7
|
def call
|
|
8
|
-
|
|
9
|
-
when "mysql2", "trilogy"
|
|
8
|
+
if database.mysql?
|
|
10
9
|
sh mysql_command
|
|
11
|
-
|
|
10
|
+
elsif database.postgresql?
|
|
12
11
|
sh psql_command
|
|
12
|
+
elsif database.sqlite?
|
|
13
|
+
sh sqlite_command
|
|
13
14
|
else
|
|
14
15
|
raise "don't know how to load #{database.adapter}"
|
|
15
16
|
end
|
|
@@ -35,6 +36,10 @@ module Backhoe
|
|
|
35
36
|
cmd
|
|
36
37
|
end
|
|
37
38
|
|
|
39
|
+
def sqlite_command
|
|
40
|
+
"#{cat} #{path} > #{database.path}"
|
|
41
|
+
end
|
|
42
|
+
|
|
38
43
|
def cat
|
|
39
44
|
path =~ /\.gz$/ ? "zcat" : "cat"
|
|
40
45
|
end
|
data/lib/backhoe/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: backhoe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Geisel
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-02-27 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -94,6 +93,20 @@ dependencies:
|
|
|
94
93
|
- - ">="
|
|
95
94
|
- !ruby/object:Gem::Version
|
|
96
95
|
version: '0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: sqlite3
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
97
110
|
- !ruby/object:Gem::Dependency
|
|
98
111
|
name: byebug
|
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -147,6 +160,7 @@ files:
|
|
|
147
160
|
- ".gitignore"
|
|
148
161
|
- ".rspec"
|
|
149
162
|
- Appraisals
|
|
163
|
+
- CLAUDE.md
|
|
150
164
|
- Gemfile
|
|
151
165
|
- LICENSE.txt
|
|
152
166
|
- README.md
|
|
@@ -155,9 +169,9 @@ files:
|
|
|
155
169
|
- bin/console
|
|
156
170
|
- bin/setup
|
|
157
171
|
- gemfiles/.bundle/config
|
|
158
|
-
- gemfiles/activerecord_7.0.gemfile
|
|
159
|
-
- gemfiles/activerecord_7.1.gemfile
|
|
160
172
|
- gemfiles/activerecord_7.2.gemfile
|
|
173
|
+
- gemfiles/activerecord_8.0.gemfile
|
|
174
|
+
- gemfiles/activerecord_8.1.gemfile
|
|
161
175
|
- lib/backhoe.rb
|
|
162
176
|
- lib/backhoe/database.rb
|
|
163
177
|
- lib/backhoe/dump.rb
|
|
@@ -167,7 +181,6 @@ homepage: https://github.com/botandrose/backhoe
|
|
|
167
181
|
licenses:
|
|
168
182
|
- MIT
|
|
169
183
|
metadata: {}
|
|
170
|
-
post_install_message:
|
|
171
184
|
rdoc_options: []
|
|
172
185
|
require_paths:
|
|
173
186
|
- lib
|
|
@@ -182,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
182
195
|
- !ruby/object:Gem::Version
|
|
183
196
|
version: '0'
|
|
184
197
|
requirements: []
|
|
185
|
-
rubygems_version: 3.
|
|
186
|
-
signing_key:
|
|
198
|
+
rubygems_version: 3.6.2
|
|
187
199
|
specification_version: 4
|
|
188
200
|
summary: Dump and load current database to and from a file.
|
|
189
201
|
test_files: []
|