dumpcar 0.2 → 0.3
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/.devcontainer/Dockerfile +0 -2
- data/.devcontainer/devcontainer.json +12 -3
- data/README.md +6 -3
- data/Rakefile +12 -0
- data/gemfiles/rails_6.0.gemfile +4 -0
- data/gemfiles/rails_6.1.gemfile +4 -0
- data/gemfiles/rails_7.0.gemfile +4 -0
- data/gemfiles/rails_7.1.gemfile +4 -0
- data/gemfiles/rails_7.2.gemfile +4 -0
- data/gemfiles/rails_8.0.gemfile +4 -0
- data/gemfiles/rails_edge.gemfile +4 -0
- data/lib/dumpcar/instance.rb +18 -4
- data/lib/dumpcar/location.rb +11 -11
- data/lib/dumpcar/version.rb +1 -1
- data/lib/rails/commands/dumpcar_command.rb +5 -3
- data/package-lock.json +8 -8
- data/package.json +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee8d684348fb3890c5e4b440c594dc98f4a088d35f508bcad10b785b1c8a786c
|
4
|
+
data.tar.gz: f4ac59ac50c529a8be9003d3f616b7e75043b87a2023a146e5fbf6730a3d3a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 463ad770e9cc2c136c471bda67fe4a526f00c6c0025c79746a4579fd72f1b72668d5dddf3e25055246b821881abfb2859d76cea7c241e7b2f53295d301f3c241
|
7
|
+
data.tar.gz: ecc724aad06a3bffe85bd4a4ab9360fa0ee95a9f0cca55f1fddc65e31714743eb5be1396d48e7d7d6e70b506c52392006af156031185055543541fd5e2d03cd1
|
data/.devcontainer/Dockerfile
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
FROM mcr.microsoft.com/devcontainers/ruby:1-3.2-bullseye
|
2
2
|
|
3
|
-
# Install Rails
|
4
|
-
RUN su vscode -c "gem install rails webdrivers"
|
5
3
|
RUN su vscode -c "/usr/local/rvm/bin/rvm fix-permissions"
|
6
4
|
|
7
5
|
# Default value to allow debug server to serve content over GitHub Codespace's port forwarding service
|
@@ -18,10 +18,19 @@
|
|
18
18
|
// "forwardPorts": [3000, 5432],
|
19
19
|
|
20
20
|
// Use 'postCreateCommand' to run commands after the container is created.
|
21
|
-
"postCreateCommand": "bin/setup"
|
22
|
-
|
21
|
+
"postCreateCommand": "bundle config set path vendor/bundle && bin/setup",
|
23
22
|
// Configure tool-specific properties.
|
24
|
-
|
23
|
+
"customizations": {
|
24
|
+
"vscode": {
|
25
|
+
"settings": {
|
26
|
+
"rubyLsp.addonSettings": {
|
27
|
+
"Ruby LSP RSpec": {
|
28
|
+
"rspecCommand": "rspec -f d"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
25
34
|
|
26
35
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
27
36
|
// "remoteUser": "root"
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Dumpcar
|
2
2
|
|
3
|
-
[](https://rubygems.org/gems/dumpcar)
|
3
|
+
[](https://rubygems.org/gems/dumpcar) [](https://github.com/wwahammy/dumpcar/actions/workflows/main.yml)
|
4
4
|
|
5
|
-
|
5
|
+
Rails commands for dumping and restoring the contents of the PostgreSQL database for your Rails application.
|
6
6
|
|
7
7
|
- Dump (`rails dumpcar:dump`) and restore your last dump (`rails dumpcar:restore`) with a single command
|
8
8
|
- Uses your Rails database credentials for your environment
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
|
-
Install the gem executing:
|
12
|
+
Install the gem by executing:
|
13
13
|
|
14
14
|
```bash
|
15
15
|
bundle add dumpcar
|
@@ -41,6 +41,9 @@ Outside of the `rails dumpcar:dump` and `rails dumpcar:restore` commands, don't
|
|
41
41
|
|
42
42
|
## Development
|
43
43
|
|
44
|
+
NOTE: Using the Devcontainer is one of the easiest ways to get setup. Unfortunately, it also requires a no-charge but proprietary
|
45
|
+
extension VSCode to use.
|
46
|
+
|
44
47
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You should run `bin/appraisal rspec` to run all of the tests on all of the supported Rails versions. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
48
|
|
46
49
|
## Contributing
|
data/Rakefile
CHANGED
@@ -8,3 +8,15 @@ RSpec::Core::RakeTask.new(:spec)
|
|
8
8
|
require "standard/rake"
|
9
9
|
|
10
10
|
task default: %i[spec standard]
|
11
|
+
|
12
|
+
namespace :clean do
|
13
|
+
desc "Clean your tmp directory of copies of files used in rspec runs"
|
14
|
+
task :tmp do
|
15
|
+
tmp_dir_path = Pathname.new(__dir__).join("spec/internal/tmp")
|
16
|
+
tmp_dir_path.children.select { |file| file.basename.to_s != ".keep" }.each(&:rmtree)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Rake::Task[:clean].enhance do
|
21
|
+
Rake::Task["clean:tmp"].invoke
|
22
|
+
end
|
data/gemfiles/rails_6.0.gemfile
CHANGED
data/gemfiles/rails_6.1.gemfile
CHANGED
data/gemfiles/rails_7.0.gemfile
CHANGED
data/gemfiles/rails_7.1.gemfile
CHANGED
data/gemfiles/rails_7.2.gemfile
CHANGED
data/gemfiles/rails_8.0.gemfile
CHANGED
data/gemfiles/rails_edge.gemfile
CHANGED
@@ -17,4 +17,8 @@ gem "appraisal", :git => "https://github.com/pboling/appraisal.git", :ref => "c3
|
|
17
17
|
gem "debug"
|
18
18
|
gem "rails", :github => "rails/rails", :branch => "main"
|
19
19
|
|
20
|
+
group :development do
|
21
|
+
gem "ruby-lsp-rspec", :require => false
|
22
|
+
end
|
23
|
+
|
20
24
|
gemspec :path => "../"
|
data/lib/dumpcar/instance.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module Dumpcar
|
2
2
|
class Instance
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require "active_model"
|
4
|
+
include ActiveModel::Model
|
5
|
+
|
6
|
+
attr_accessor :connection, :location, :pg, :base_dir
|
7
|
+
def initialize(attributes = {})
|
8
|
+
cleanup_arguments(attributes)
|
9
|
+
@connection = Dumpcar::Util.get_connection_db_config
|
10
|
+
@location = Location.new(base_dir)
|
11
|
+
@pg = Pg.new(connection)
|
7
12
|
end
|
8
13
|
|
9
14
|
def dump
|
@@ -13,5 +18,14 @@ module Dumpcar
|
|
13
18
|
def restore
|
14
19
|
@pg.restore(@location.last)
|
15
20
|
end
|
21
|
+
|
22
|
+
def cleanup_arguments(arguments)
|
23
|
+
arguments = arguments.to_h.with_indifferent_access
|
24
|
+
unless arguments.has_key?("base_dir")
|
25
|
+
arguments["base_dir"] = Rails.root.join("db/dumps")
|
26
|
+
end
|
27
|
+
|
28
|
+
assign_attributes(arguments)
|
29
|
+
end
|
16
30
|
end
|
17
31
|
end
|
data/lib/dumpcar/location.rb
CHANGED
@@ -4,18 +4,18 @@ module Dumpcar
|
|
4
4
|
TIMESTAMP_GLOB = 14.times.map { "[0-9]" }.join
|
5
5
|
TIMESTAMP_FILE_GLOB = TIMESTAMP_GLOB + "*.dump"
|
6
6
|
|
7
|
-
attr_reader :
|
8
|
-
def initialize(
|
9
|
-
@
|
7
|
+
attr_reader :base_dir
|
8
|
+
def initialize(base_dir)
|
9
|
+
@base_dir = Pathname.new base_dir
|
10
10
|
end
|
11
11
|
|
12
12
|
def dumps
|
13
|
-
|
14
|
-
|
13
|
+
prepare_base_dir!
|
14
|
+
base_dir.glob(TIMESTAMP_FILE_GLOB)
|
15
15
|
end
|
16
16
|
|
17
17
|
def first
|
18
|
-
|
18
|
+
prepare_base_dir!
|
19
19
|
dumps.first
|
20
20
|
end
|
21
21
|
|
@@ -24,13 +24,13 @@ module Dumpcar
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def last
|
27
|
-
|
27
|
+
prepare_base_dir!
|
28
28
|
dumps.last
|
29
29
|
end
|
30
30
|
|
31
31
|
def next
|
32
|
-
|
33
|
-
|
32
|
+
prepare_base_dir!
|
33
|
+
base_dir.join(from_time + ".dump").to_s
|
34
34
|
end
|
35
35
|
|
36
36
|
def from_time(time = Time.now.utc)
|
@@ -39,8 +39,8 @@ module Dumpcar
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
def
|
43
|
-
FileUtils.mkdir_p
|
42
|
+
def prepare_base_dir!
|
43
|
+
FileUtils.mkdir_p base_dir
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/dumpcar/version.rb
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
class DumpcarCommand < Rails::Command::Base
|
2
|
-
class_option :
|
2
|
+
class_option :base_dir, type: :string, desc: "the location of your DB dumps, defaults to Rails.root.join('db/dumps')"
|
3
3
|
|
4
4
|
desc "dump", "Dump postgres backup file"
|
5
5
|
def dump
|
6
|
+
(Rails.version < "6.1") ? require_application_and_environment! : boot_application!
|
6
7
|
require "dumpcar"
|
7
|
-
Dumpcar::Instance.new.dump
|
8
|
+
Dumpcar::Instance.new(options).dump
|
8
9
|
end
|
9
10
|
|
10
11
|
desc "restore", "Restore postgres backup file"
|
11
12
|
def restore
|
13
|
+
(Rails.version < "6.1") ? require_application_and_environment! : boot_application!
|
12
14
|
require "dumpcar"
|
13
|
-
Dumpcar::Instance.new.restore
|
15
|
+
Dumpcar::Instance.new(options).restore
|
14
16
|
end
|
15
17
|
end
|
data/package-lock.json
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
"": {
|
7
7
|
"devDependencies": {
|
8
8
|
"husky": "^9.0",
|
9
|
-
"lint-staged": "^16.
|
10
|
-
"prettier": "^3.
|
9
|
+
"lint-staged": "^16.1",
|
10
|
+
"prettier": "^3.6"
|
11
11
|
}
|
12
12
|
},
|
13
13
|
"node_modules/ansi-escapes": {
|
@@ -252,9 +252,9 @@
|
|
252
252
|
}
|
253
253
|
},
|
254
254
|
"node_modules/lint-staged": {
|
255
|
-
"version": "16.1.
|
256
|
-
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-16.1.
|
257
|
-
"integrity": "sha512-
|
255
|
+
"version": "16.1.2",
|
256
|
+
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-16.1.2.tgz",
|
257
|
+
"integrity": "sha512-sQKw2Si2g9KUZNY3XNvRuDq4UJqpHwF0/FQzZR2M7I5MvtpWvibikCjUVJzZdGE0ByurEl3KQNvsGetd1ty1/Q==",
|
258
258
|
"dev": true,
|
259
259
|
"license": "MIT",
|
260
260
|
"dependencies": {
|
@@ -440,9 +440,9 @@
|
|
440
440
|
}
|
441
441
|
},
|
442
442
|
"node_modules/prettier": {
|
443
|
-
"version": "3.
|
444
|
-
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.
|
445
|
-
"integrity": "sha512-
|
443
|
+
"version": "3.6.0",
|
444
|
+
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.0.tgz",
|
445
|
+
"integrity": "sha512-ujSB9uXHJKzM/2GBuE0hBOUgC77CN3Bnpqa+g80bkv3T3A93wL/xlzDATHhnhkzifz/UE2SNOvmbTz5hSkDlHw==",
|
446
446
|
"dev": true,
|
447
447
|
"license": "MIT",
|
448
448
|
"bin": {
|
data/package.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"devDependencies": {
|
3
3
|
"husky": "^9.0",
|
4
|
-
"lint-staged": "^16.
|
5
|
-
"prettier": "^3.
|
4
|
+
"lint-staged": "^16.1",
|
5
|
+
"prettier": "^3.6"
|
6
6
|
},
|
7
7
|
"scripts": {
|
8
8
|
"prepare": "husky"
|
@@ -10,6 +10,6 @@
|
|
10
10
|
"lint-staged": {
|
11
11
|
"*.{js,css,md,yml}": "prettier --write",
|
12
12
|
"*.{rb,rake,gemspec,ru}": "bin/standardrb --fix",
|
13
|
-
"Gemfile": "bin/standardrb --fix"
|
13
|
+
"{Gemfile,Rakefile}": "bin/standardrb --fix"
|
14
14
|
}
|
15
15
|
}
|