backhoe 0.5.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2eedc96f1b7466ebc166988dce01252aec90d14fcadd216cf926699e5d97b2e4
4
- data.tar.gz: ac773a88ca48fa6f3d89228b6e3ea319bec0e64e4a5ab0ce2fbbd67e08a3127f
3
+ metadata.gz: 0da54b2284a8f477b20d0175cdb1023ffd28e03365598000e8cdf7403fb12dc4
4
+ data.tar.gz: a298c3b656be2bd65b52731ae749d27317b5bbd26e2401370a4ccbbfc22f73c1
5
5
  SHA512:
6
- metadata.gz: ad26930dc3f9f53b3fbc62909fcd0942f478dd97c496ca3cb5127d19d81fdedd24db74358d33c3c797084c75bef77f1402ec308159c59265642f2093eda982eb
7
- data.tar.gz: eb1a3ddb18501571bc2cbd2d3fd9af921d75788f5fc9c43ec7cfac20437c834b470ed335ce38223212cdc7950e18e09c16148a134c486b5e6c138428c4a16be6
6
+ metadata.gz: 90cf47702daa8c845795bfba48175718016f3f929b34c3924d86ad3d51979ca91e2cfae4973d2839197ec333e8735c92b02347095256674f444998ec951118e8
7
+ data.tar.gz: 335c9e882afd7c4f8591f8b449b4cc1dc3205d74d7194a1112a0b2b9492af30223ebddad7c18583db96471ac2663e7b360eb569a40e8b9e91bd5ba6db4af32a2
@@ -5,26 +5,18 @@ jobs:
5
5
  strategy:
6
6
  fail-fast: false
7
7
  matrix:
8
- gemfile: [ activerecord_5.1, activerecord_5.2, activerecord_6.0, activerecord_6.1, activerecord_7.0 ]
9
- ruby: [ 2.6, 2.7, 3.0 ]
10
- exclude:
11
- - gemfile: activerecord_5.1
12
- ruby: 3.0
13
- - gemfile: activerecord_5.2
14
- ruby: 3.0
15
- - gemfile: activerecord_7.0
16
- ruby: 2.6
8
+ gemfile: [ activerecord_6.0, activerecord_6.1, activerecord_7.0 ]
9
+ ruby: [ '3.0', 3.1, 3.2 ]
17
10
 
18
- runs-on: ubuntu-18.04
11
+ runs-on: ubuntu-20.04
19
12
  env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
20
13
  BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
21
14
  steps:
22
- - uses: actions/checkout@v2
23
- - uses: shogo82148/actions-setup-mysql@v1
24
- with:
25
- mysql-version: 5.7
26
- my-cnf: |
27
- socket=/tmp/mysql.sock
15
+ - name: Set up MySQL
16
+ run: |
17
+ sudo /etc/init.d/mysql start
18
+ sudo mysql -uroot -proot -e"ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '';"
19
+ - uses: actions/checkout@v3
28
20
  - uses: ruby/setup-ruby@v1
29
21
  with:
30
22
  ruby-version: ${{ matrix.ruby }}
data/.gitignore CHANGED
@@ -8,6 +8,8 @@
8
8
  /tmp/
9
9
  /.ruby-version
10
10
  /Gemfile.lock
11
+ /gemfiles/*.lock
12
+ /.byebug_history
11
13
 
12
14
  # rspec failure tracking
13
15
  .rspec_status
data/Appraisals CHANGED
@@ -1,11 +1,3 @@
1
- appraise "activerecord-5.1" do
2
- gem "activerecord", "~>5.1.0"
3
- end
4
-
5
- appraise "activerecord-5.2" do
6
- gem "activerecord", "~>5.2.0"
7
- end
8
-
9
1
  appraise "activerecord-6.0" do
10
2
  gem "activerecord", "~>6.0.0"
11
3
  end
data/README.md CHANGED
@@ -3,31 +3,27 @@
3
3
 
4
4
  Dump and load current ActiveRecord database to and from a file.
5
5
 
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
6
+ ## Usage
9
7
 
10
8
  ```ruby
11
- gem 'backhoe'
9
+ # Dump
10
+ Backhoe.dump "data.sql" # dumps db to db/data.sql
11
+ Backhoe.dump "data.sql.gz" # => can also dump a gzipped sql file
12
+ Backhoe.dump "data.sql", skip_tables: [:comments], skip_columns: { users: [:password] } # can skip whole tables or just specific columns
13
+
14
+ # Load
15
+ Backhoe.load "data.sql" # loads db from db/data.sql
16
+ Backhoe.load "data.sql.gz" # => can also load a gzipped sql file
17
+ Backhoe.load "data.sql", drop_and_create: true # injects DROP and CREATE statements into the SQL invocation
18
+
19
+ # Backup db to S3
20
+ Backhoe.backup "bucket-name/folder" # => dumps db to e.g. s3://bucket-name/folder/2023-04-09T16:41:26Z.sql.gz via AWS CLI, assuming that credentials are already configured.
21
+ Backhoe.backup "bucket-name/folder", access_key: "abc123", secret_key: "def456" # => manually specify AWS creds
12
22
  ```
13
23
 
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install backhoe
21
-
22
- ## Usage
23
-
24
- TODO: Write usage instructions here
25
-
26
24
  ## Development
27
25
 
28
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
-
30
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
27
 
32
28
  ## Contributing
33
29
 
data/backhoe.gemspec CHANGED
@@ -23,9 +23,10 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency "activerecord"
25
25
 
26
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rake"
27
27
  spec.add_development_dependency "rspec", "~> 3.0"
28
28
  spec.add_development_dependency "appraisal"
29
29
  spec.add_development_dependency "mysql2"
30
30
  spec.add_development_dependency "byebug"
31
+ spec.add_development_dependency "timecop"
31
32
  end
@@ -0,0 +1,28 @@
1
+ module Backhoe
2
+ class Backup < Struct.new(:s3_path, :access_key, :secret_key)
3
+ def call
4
+ Backhoe.dump path
5
+ Kernel.system "#{creds} aws s3 mv #{path} s3://#{s3_path}/#{filename}".strip
6
+ end
7
+
8
+ private
9
+
10
+ def creds
11
+ if access_key && secret_key
12
+ "AWS_ACCESS_KEY_ID=#{access_key} AWS_SECRET_ACCESS_KEY=#{secret_key}"
13
+ end
14
+ end
15
+
16
+ def path
17
+ "/tmp/#{filename}"
18
+ end
19
+
20
+ def filename
21
+ @filename ||= begin
22
+ require "time"
23
+ "#{Time.now.utc.iso8601}.sql.gz"
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,42 @@
1
+ module Backhoe
2
+ class Database
3
+ def initialize config=load_config
4
+ @config = config
5
+ end
6
+
7
+ attr_reader :config
8
+
9
+ def current_environment_name
10
+ [
11
+ defined?(Rails) && Rails.env,
12
+ ENV["RAILS_ENV"],
13
+ "development",
14
+ ].find(&:itself)
15
+ end
16
+
17
+ def to_mysql_options
18
+ options = " -u #{config["username"]}"
19
+ options += " -p'#{config["password"]}'" if config["password"]
20
+ options += " -h #{config["host"]}" if config["host"]
21
+ options += " -S #{config["socket"]}" if config["socket"]
22
+ options
23
+ end
24
+
25
+ def name
26
+ config["database"]
27
+ end
28
+
29
+ private
30
+
31
+ def load_config
32
+ configs = ActiveRecord::Base.configurations
33
+ config = configs.configs_for(env_name: current_environment_name).first
34
+ hash = if config.respond_to?(:configuration_hash)
35
+ config.configuration_hash # rails 7
36
+ else
37
+ config.config # rails 6
38
+ end
39
+ HashWithIndifferentAccess.new(hash)
40
+ end
41
+ end
42
+ end
@@ -1,50 +1,49 @@
1
- require "backhoe/base"
1
+ require "rake"
2
2
 
3
3
  module Backhoe
4
- class Mysql < Base
5
- def dump skip_tables: []
6
- mysqldump = `which mysqldump`.strip
7
- raise RuntimeError, "Cannot find mysqldump." if mysqldump.blank?
8
- sh "#{mysqldump} --no-create-db --single-transaction --quick -e #{skip_table_options(skip_tables)} #{mysql_options} > #{file_path}"
4
+ class Dump < Struct.new(:database, :file_path, :skip_tables, :skip_columns)
5
+ include Rake::DSL
6
+
7
+ def initialize *args
8
+ super
9
+ self.skip_tables ||= []
10
+ self.skip_columns ||= {}
9
11
  end
10
12
 
11
- def load
12
- mysql = `which mysql`.strip
13
- raise RuntimeError, "Cannot find mysql." if mysql.blank?
14
- sh "#{mysql} #{mysql_options} < #{file_path}"
13
+ def call
14
+ if skip_columns.any?
15
+ SanitizedDatabase.new(skip_columns, file_path).dump do |tables|
16
+ self.skip_tables += tables
17
+ dump
18
+ end
19
+ else
20
+ dump
21
+ end
15
22
  end
16
23
 
17
24
  private
18
25
 
19
- def skip_table_options skip_tables
20
- skip_tables.map do |table|
21
- "--ignore-table=#{config["database"]}.#{table}"
22
- end.join(" ")
26
+ def dump
27
+ sh "#{mysqldump} --no-create-db --single-transaction --quick -e #{skip_table_options} #{database.to_mysql_options} #{database.name} | #{pipe} > #{file_path}"
23
28
  end
24
-
25
- def mysql_options
26
- options = " -u #{config["username"]}"
27
- options += " -p'#{config["password"]}'" if config["password"]
28
- options += " -h #{config["host"]}" if config["host"]
29
- options += " -S #{config["socket"]}" if config["socket"]
30
- options += " '#{config["database"]}'"
29
+
30
+ private
31
+
32
+ def mysqldump
33
+ cmd = `which mysqldump`.strip
34
+ raise RuntimeError, "Cannot find mysqldump." if cmd.blank?
35
+ cmd
31
36
  end
32
- end
33
37
 
34
- module MysqlSkipColumns
35
- def dump **options
36
- if skip_columns = options.delete(:skip_columns)
37
- SanitizedDatabase.new(skip_columns, file_path).dump do |skip_tables|
38
- options[:skip_tables] ||= []
39
- options[:skip_tables] += skip_tables
40
- super **options
41
- end
42
- else
43
- super
44
- end
38
+ def pipe
39
+ file_path =~ /\.gz$/ ? "gzip -9f" : "cat"
45
40
  end
46
41
 
47
- private
42
+ def skip_table_options
43
+ skip_tables.map do |table|
44
+ "--ignore-table=#{database.name}.#{table}"
45
+ end.join(" ")
46
+ end
48
47
 
49
48
  class SanitizedDatabase < Struct.new(:config, :file_path)
50
49
  def dump
@@ -89,8 +88,6 @@ module Backhoe
89
88
  end
90
89
  end
91
90
  end
92
- Mysql.prepend MysqlSkipColumns
93
-
94
- Mysql2 = Mysql
95
91
  end
96
92
 
93
+
@@ -0,0 +1,45 @@
1
+ require "rake"
2
+
3
+ module Backhoe
4
+ class Load < Struct.new(:database, :file_path, :drop_and_create)
5
+ include Rake::DSL
6
+
7
+ def call
8
+ sh command
9
+ end
10
+
11
+ private
12
+
13
+ def command
14
+ cmd = "#{cat} #{file_path} | "
15
+ cmd += if drop_and_create
16
+ "#{pipe} | #{mysql} #{database.to_mysql_options}"
17
+ else
18
+ "#{mysql} #{database.to_mysql_options} #{database.name}"
19
+ end
20
+ end
21
+
22
+ def cat
23
+ file_path =~ /\.gz$/ ? "zcat" : "cat"
24
+ end
25
+
26
+ def pipe
27
+ if drop_and_create
28
+ "(echo -n '#{<<~SQL}' && cat)"
29
+ DROP DATABASE IF EXISTS #{database.name};
30
+ CREATE DATABASE #{database.name};
31
+ USE #{database.name};
32
+ SQL
33
+ else
34
+ "cat"
35
+ end
36
+ end
37
+
38
+ def mysql
39
+ cmd = `which mysql`.strip
40
+ raise RuntimeError, "Cannot find mysql." if cmd.blank?
41
+ cmd
42
+ end
43
+ end
44
+ end
45
+
@@ -1,3 +1,3 @@
1
1
  module Backhoe
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/lib/backhoe.rb CHANGED
@@ -1,41 +1,22 @@
1
1
  require "backhoe/version"
2
- require "backhoe/mysql"
3
- require "backhoe/postgresql"
4
- require "backhoe/sqlite"
2
+ require "backhoe/dump"
3
+ require "backhoe/load"
4
+ require "backhoe/backup"
5
+ require "backhoe/database"
5
6
  require "active_record"
6
7
 
7
8
  module Backhoe
8
- mattr_accessor(:file_path) { "db/data.sql" }
9
-
10
9
  class << self
11
- def dump file_path: Backhoe.file_path, **options
12
- autodetect_adapter.new(database_config, file_path).dump **options
10
+ def dump file_path, skip_tables: [], skip_columns: {}
11
+ Dump.new(Database.new, file_path, skip_tables, skip_columns).call
13
12
  end
14
13
 
15
- def load file_path: Backhoe.file_path
16
- autodetect_adapter.new(database_config, file_path).load
14
+ def load file_path, drop_and_create: false
15
+ Load.new(Database.new, file_path, drop_and_create).call
17
16
  end
18
17
 
19
- private
20
-
21
- def autodetect_adapter
22
- const_get(database_config["adapter"].camelize)
23
- end
24
-
25
- def database_config
26
- env = Rails.env || "development"
27
- configs = ActiveRecord::Base.configurations
28
- hash = if configs.respond_to?(:configs_for)
29
- config = configs.configs_for(env_name: env).first
30
- if config.respond_to?(:configuration_hash)
31
- config.configuration_hash # rails 7
32
- else
33
- config.config # rails 6
34
- end
35
- else
36
- configs[env] # rails 5
37
- end
38
- HashWithIndifferentAccess.new(hash)
18
+ def backup s3_path, access_key: nil, secret_key: nil
19
+ Backup.new(s3_path, access_key, secret_key).call
39
20
  end
40
21
  end
41
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backhoe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-16 00:00:00.000000000 Z
11
+ date: 2023-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: timecop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Dump and load current database to and from a file.
98
112
  email:
99
113
  - micah@botandrose.com
@@ -113,21 +127,14 @@ files:
113
127
  - bin/console
114
128
  - bin/setup
115
129
  - gemfiles/.bundle/config
116
- - gemfiles/activerecord_5.1.gemfile
117
- - gemfiles/activerecord_5.1.gemfile.lock
118
- - gemfiles/activerecord_5.2.gemfile
119
- - gemfiles/activerecord_5.2.gemfile.lock
120
130
  - gemfiles/activerecord_6.0.gemfile
121
- - gemfiles/activerecord_6.0.gemfile.lock
122
131
  - gemfiles/activerecord_6.1.gemfile
123
- - gemfiles/activerecord_6.1.gemfile.lock
124
132
  - gemfiles/activerecord_7.0.gemfile
125
- - gemfiles/activerecord_7.0.gemfile.lock
126
133
  - lib/backhoe.rb
127
- - lib/backhoe/base.rb
128
- - lib/backhoe/mysql.rb
129
- - lib/backhoe/postgresql.rb
130
- - lib/backhoe/sqlite.rb
134
+ - lib/backhoe/backup.rb
135
+ - lib/backhoe/database.rb
136
+ - lib/backhoe/dump.rb
137
+ - lib/backhoe/load.rb
131
138
  - lib/backhoe/version.rb
132
139
  homepage: https://github.com/botandrose/backhoe
133
140
  licenses:
@@ -148,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
155
  - !ruby/object:Gem::Version
149
156
  version: '0'
150
157
  requirements: []
151
- rubygems_version: 3.2.32
158
+ rubygems_version: 3.3.26
152
159
  signing_key:
153
160
  specification_version: 4
154
161
  summary: Dump and load current database to and from a file.
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~>5.1.0"
6
-
7
- gemspec path: "../"
@@ -1,65 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- backhoe (0.4.1)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (5.1.7)
11
- activesupport (= 5.1.7)
12
- activerecord (5.1.7)
13
- activemodel (= 5.1.7)
14
- activesupport (= 5.1.7)
15
- arel (~> 8.0)
16
- activesupport (5.1.7)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- appraisal (2.3.0)
22
- bundler
23
- rake
24
- thor (>= 0.14.0)
25
- arel (8.0.0)
26
- byebug (11.1.3)
27
- concurrent-ruby (1.1.8)
28
- diff-lcs (1.4.4)
29
- i18n (1.8.7)
30
- concurrent-ruby (~> 1.0)
31
- minitest (5.14.3)
32
- mysql2 (0.5.3)
33
- rake (10.5.0)
34
- rspec (3.10.0)
35
- rspec-core (~> 3.10.0)
36
- rspec-expectations (~> 3.10.0)
37
- rspec-mocks (~> 3.10.0)
38
- rspec-core (3.10.1)
39
- rspec-support (~> 3.10.0)
40
- rspec-expectations (3.10.1)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.10.0)
43
- rspec-mocks (3.10.2)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.10.0)
46
- rspec-support (3.10.2)
47
- thor (1.1.0)
48
- thread_safe (0.3.6)
49
- tzinfo (1.2.9)
50
- thread_safe (~> 0.1)
51
-
52
- PLATFORMS
53
- ruby
54
-
55
- DEPENDENCIES
56
- activerecord (~> 5.1.0)
57
- appraisal
58
- backhoe!
59
- byebug
60
- mysql2
61
- rake (~> 10.0)
62
- rspec (~> 3.0)
63
-
64
- BUNDLED WITH
65
- 2.2.32
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~>5.2.0"
6
-
7
- gemspec path: "../"
@@ -1,65 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- backhoe (0.4.1)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (5.2.4.4)
11
- activesupport (= 5.2.4.4)
12
- activerecord (5.2.4.4)
13
- activemodel (= 5.2.4.4)
14
- activesupport (= 5.2.4.4)
15
- arel (>= 9.0)
16
- activesupport (5.2.4.4)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 0.7, < 2)
19
- minitest (~> 5.1)
20
- tzinfo (~> 1.1)
21
- appraisal (2.3.0)
22
- bundler
23
- rake
24
- thor (>= 0.14.0)
25
- arel (9.0.0)
26
- byebug (11.1.3)
27
- concurrent-ruby (1.1.8)
28
- diff-lcs (1.4.4)
29
- i18n (1.8.7)
30
- concurrent-ruby (~> 1.0)
31
- minitest (5.14.3)
32
- mysql2 (0.5.3)
33
- rake (10.5.0)
34
- rspec (3.10.0)
35
- rspec-core (~> 3.10.0)
36
- rspec-expectations (~> 3.10.0)
37
- rspec-mocks (~> 3.10.0)
38
- rspec-core (3.10.1)
39
- rspec-support (~> 3.10.0)
40
- rspec-expectations (3.10.1)
41
- diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.10.0)
43
- rspec-mocks (3.10.2)
44
- diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.10.0)
46
- rspec-support (3.10.2)
47
- thor (1.1.0)
48
- thread_safe (0.3.6)
49
- tzinfo (1.2.9)
50
- thread_safe (~> 0.1)
51
-
52
- PLATFORMS
53
- ruby
54
-
55
- DEPENDENCIES
56
- activerecord (~> 5.2.0)
57
- appraisal
58
- backhoe!
59
- byebug
60
- mysql2
61
- rake (~> 10.0)
62
- rspec (~> 3.0)
63
-
64
- BUNDLED WITH
65
- 2.2.32
@@ -1,65 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- backhoe (0.4.1)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (6.0.3.4)
11
- activesupport (= 6.0.3.4)
12
- activerecord (6.0.3.4)
13
- activemodel (= 6.0.3.4)
14
- activesupport (= 6.0.3.4)
15
- activesupport (6.0.3.4)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- zeitwerk (~> 2.2, >= 2.2.2)
21
- appraisal (2.3.0)
22
- bundler
23
- rake
24
- thor (>= 0.14.0)
25
- byebug (11.1.3)
26
- concurrent-ruby (1.1.8)
27
- diff-lcs (1.4.4)
28
- i18n (1.8.7)
29
- concurrent-ruby (~> 1.0)
30
- minitest (5.14.3)
31
- mysql2 (0.5.3)
32
- rake (10.5.0)
33
- rspec (3.10.0)
34
- rspec-core (~> 3.10.0)
35
- rspec-expectations (~> 3.10.0)
36
- rspec-mocks (~> 3.10.0)
37
- rspec-core (3.10.1)
38
- rspec-support (~> 3.10.0)
39
- rspec-expectations (3.10.1)
40
- diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.10.0)
42
- rspec-mocks (3.10.2)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.10.0)
45
- rspec-support (3.10.2)
46
- thor (1.1.0)
47
- thread_safe (0.3.6)
48
- tzinfo (1.2.9)
49
- thread_safe (~> 0.1)
50
- zeitwerk (2.4.2)
51
-
52
- PLATFORMS
53
- ruby
54
-
55
- DEPENDENCIES
56
- activerecord (~> 6.0.0)
57
- appraisal
58
- backhoe!
59
- byebug
60
- mysql2
61
- rake (~> 10.0)
62
- rspec (~> 3.0)
63
-
64
- BUNDLED WITH
65
- 2.2.32
@@ -1,64 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- backhoe (0.4.1)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (6.1.1)
11
- activesupport (= 6.1.1)
12
- activerecord (6.1.1)
13
- activemodel (= 6.1.1)
14
- activesupport (= 6.1.1)
15
- activesupport (6.1.1)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 1.6, < 2)
18
- minitest (>= 5.1)
19
- tzinfo (~> 2.0)
20
- zeitwerk (~> 2.3)
21
- appraisal (2.3.0)
22
- bundler
23
- rake
24
- thor (>= 0.14.0)
25
- byebug (11.1.3)
26
- concurrent-ruby (1.1.8)
27
- diff-lcs (1.4.4)
28
- i18n (1.8.7)
29
- concurrent-ruby (~> 1.0)
30
- minitest (5.14.3)
31
- mysql2 (0.5.3)
32
- rake (10.5.0)
33
- rspec (3.10.0)
34
- rspec-core (~> 3.10.0)
35
- rspec-expectations (~> 3.10.0)
36
- rspec-mocks (~> 3.10.0)
37
- rspec-core (3.10.1)
38
- rspec-support (~> 3.10.0)
39
- rspec-expectations (3.10.1)
40
- diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.10.0)
42
- rspec-mocks (3.10.2)
43
- diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.10.0)
45
- rspec-support (3.10.2)
46
- thor (1.1.0)
47
- tzinfo (2.0.4)
48
- concurrent-ruby (~> 1.0)
49
- zeitwerk (2.4.2)
50
-
51
- PLATFORMS
52
- ruby
53
-
54
- DEPENDENCIES
55
- activerecord (~> 6.1.0)
56
- appraisal
57
- backhoe!
58
- byebug
59
- mysql2
60
- rake (~> 10.0)
61
- rspec (~> 3.0)
62
-
63
- BUNDLED WITH
64
- 2.2.32
@@ -1,62 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- backhoe (0.4.1)
5
- activerecord
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activemodel (7.0.1)
11
- activesupport (= 7.0.1)
12
- activerecord (7.0.1)
13
- activemodel (= 7.0.1)
14
- activesupport (= 7.0.1)
15
- activesupport (7.0.1)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 1.6, < 2)
18
- minitest (>= 5.1)
19
- tzinfo (~> 2.0)
20
- appraisal (2.4.1)
21
- bundler
22
- rake
23
- thor (>= 0.14.0)
24
- byebug (11.1.3)
25
- concurrent-ruby (1.1.9)
26
- diff-lcs (1.5.0)
27
- i18n (1.8.11)
28
- concurrent-ruby (~> 1.0)
29
- minitest (5.15.0)
30
- mysql2 (0.5.3)
31
- rake (10.5.0)
32
- rspec (3.10.0)
33
- rspec-core (~> 3.10.0)
34
- rspec-expectations (~> 3.10.0)
35
- rspec-mocks (~> 3.10.0)
36
- rspec-core (3.10.1)
37
- rspec-support (~> 3.10.0)
38
- rspec-expectations (3.10.2)
39
- diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.10.0)
41
- rspec-mocks (3.10.2)
42
- diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.10.0)
44
- rspec-support (3.10.3)
45
- thor (1.2.1)
46
- tzinfo (2.0.4)
47
- concurrent-ruby (~> 1.0)
48
-
49
- PLATFORMS
50
- x86_64-linux
51
-
52
- DEPENDENCIES
53
- activerecord (~> 7.0.0)
54
- appraisal
55
- backhoe!
56
- byebug
57
- mysql2
58
- rake (~> 10.0)
59
- rspec (~> 3.0)
60
-
61
- BUNDLED WITH
62
- 2.2.32
data/lib/backhoe/base.rb DELETED
@@ -1,14 +0,0 @@
1
- require "rake"
2
-
3
- module Backhoe
4
- class Base < Struct.new(:config, :file_path)
5
- include Rake::DSL
6
-
7
- private
8
-
9
- def database
10
- config["database"]
11
- end
12
- end
13
- end
14
-
@@ -1,18 +0,0 @@
1
- require "backhoe/base"
2
-
3
- module Backhoe
4
- class Postgresql < Base
5
- def dump **_
6
- pg_dump = `which pg_dump`.strip
7
- raise RuntimeError, "Cannot find pg_dump." if pg_dump.blank?
8
- sh "#{pg_dump} -c -f#{file_path} #{database}"
9
- end
10
-
11
- def load
12
- psql = `which psql`.strip
13
- raise RuntimeError, "Cannot find psql." if psql.blank?
14
- sh "#{psql} -P pager=off -q -d#{database} -f#{file_path}"
15
- end
16
- end
17
- end
18
-
@@ -1,15 +0,0 @@
1
- require "backhoe/base"
2
- require "fileutils"
3
-
4
- module Backhoe
5
- class Sqlite3 < Base
6
- def dump **_
7
- FileUtils.cp database, file_path
8
- end
9
-
10
- def load
11
- FileUtils.cp file_path, database
12
- end
13
- end
14
- end
15
-