db_stager 0.2.1 → 1.0.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/Gemfile.lock +1 -1
- data/README.md +47 -5
- data/db_stager.gemspec +2 -2
- data/lib/db_stager/cli.rb +3 -2
- data/lib/db_stager/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afc0778cda3b7cf0e73f56f748a14f6fa0adc6ae
|
4
|
+
data.tar.gz: c195aec4e4d0ad80d47bae96f64218880b57a723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7d89ea1be63280715cde99ce4a19d0770526cf0daea4023f7265bf32d37c7dda365dfcffb9ed12f6342a1644be7045ef15bf4983a630fdc68a39c40d0b48e3f
|
7
|
+
data.tar.gz: 39cdf412e03565a8b5bd23e5007569f011ca7d8d87ac546a4214cb76e6d8b390f501e7adf3d8c98a2d2072f8cda116cd329c60449ad46c75cfb9fce98c244efd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# This gem has been renamed to stage_hand. Find it at [Rubygems.org](https://rubygems.org/gems/stage_hand) or [Gitlab](https://gitlab.com/notch8/stage_hand)
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/db_stager`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
3
|
|
5
4
|
Perform backups and restores of databases, scrubbing records along the way. This allows taking limited snapshots of large databases and keeps customer info out of your staging site.
|
6
5
|
|
@@ -9,7 +8,7 @@ Perform backups and restores of databases, scrubbing records along the way. This
|
|
9
8
|
Add this line to your application's Gemfile:
|
10
9
|
|
11
10
|
```ruby
|
12
|
-
gem 'db_stager'
|
11
|
+
gem 'db_stager', require: false
|
13
12
|
```
|
14
13
|
|
15
14
|
And then execute:
|
@@ -22,7 +21,50 @@ Or install it yourself as:
|
|
22
21
|
|
23
22
|
## Usage
|
24
23
|
|
25
|
-
|
24
|
+
Generate an example config file
|
25
|
+
|
26
|
+
`db_stager install`
|
27
|
+
|
28
|
+
Create a new, modified copy of the production database
|
29
|
+
|
30
|
+
`db_stager capture -e production`
|
31
|
+
|
32
|
+
Load the current database file, currently just does `rake db:structure:load` but may be exapnded in the future
|
33
|
+
|
34
|
+
`db_stager load -e staging`
|
35
|
+
|
36
|
+
## Configuration
|
37
|
+
|
38
|
+
DbStager uses a configuration file found in config/stage_hand.yml. There are two sections of this file.
|
39
|
+
|
40
|
+
### excluded_tables
|
41
|
+
|
42
|
+
This is a list of all the tables to exclude. These tables are skipped by data insertion, but they are reset to the current schema currently. schema_migrations is always in the excluded list, though the structure load will set the values of that table to the most recent migration.
|
43
|
+
|
44
|
+
```yaml
|
45
|
+
excluded_tables:
|
46
|
+
- sites
|
47
|
+
- secrets
|
48
|
+
```
|
49
|
+
|
50
|
+
### fields
|
51
|
+
|
52
|
+
Here is where the real magic happens. You can specify fields to either be set to blank (by using nil or false) or by evaluating code. [Faker](https://github.com/stympy/faker) is included to make doing so easy. There is also a special variable called `existing_value` which contains the value before any changes. These fields will be changed in flight to the sql file and thus sensitive data can be removed from the production data dump.
|
53
|
+
|
54
|
+
```yaml
|
55
|
+
fields:
|
56
|
+
users:
|
57
|
+
email: "existing_value.match('notch8.com') ? existing_value : Faker::Internet.unique.email"
|
58
|
+
zip: false
|
59
|
+
action_items:
|
60
|
+
name: "Faker::Name.unique.name"
|
61
|
+
```
|
62
|
+
|
63
|
+
## TODO
|
64
|
+
|
65
|
+
-[ ] File upload
|
66
|
+
-[ ] File Download
|
67
|
+
-[ ] Ability to limit the number of rows to insert per table
|
26
68
|
|
27
69
|
## Development
|
28
70
|
|
@@ -32,7 +74,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
74
|
|
33
75
|
## Contributing
|
34
76
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://
|
77
|
+
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/notch8/db_stager. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
78
|
|
37
79
|
## License
|
38
80
|
|
data/db_stager.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["rob@notch8.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{DB Stager backups and restores databases for staging. Allows scrubbing of records.}
|
13
|
-
spec.description = %q{
|
14
|
-
spec.homepage = "https://gitlab.com/notch8/
|
13
|
+
spec.description = %q{This gem has been renamed to stage_hand. Find it at [Rubygems.org](https://rubygems.org/gems/stage_hand) or [Gitlab](https://gitlab.com/notch8/stage_hand)}
|
14
|
+
spec.homepage = "https://gitlab.com/notch8/stage_hand"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
data/lib/db_stager/cli.rb
CHANGED
@@ -34,7 +34,8 @@ module DbStager
|
|
34
34
|
if fields[table_name]
|
35
35
|
fields[table_name].each do |field_name, task|
|
36
36
|
if task
|
37
|
-
item[field_name.to_sym]
|
37
|
+
existing_value = item[field_name.to_sym]
|
38
|
+
item[field_name.to_sym] = eval(task)
|
38
39
|
else
|
39
40
|
item[field_name.to_sym] = nil
|
40
41
|
end
|
@@ -74,7 +75,7 @@ module DbStager
|
|
74
75
|
return @config_file if @config_file
|
75
76
|
config_file_path = File.join(Dir.pwd, 'config', 'stage_hand.yml')
|
76
77
|
if File.exists?(config_file_path)
|
77
|
-
@config_file = Hashie::Mash.load(
|
78
|
+
@config_file = Hashie::Mash.load(config_file_path)
|
78
79
|
else
|
79
80
|
@config_file = {}
|
80
81
|
end
|
data/lib/db_stager/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_stager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Kaufman
|
@@ -136,9 +136,8 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1.9'
|
139
|
-
description:
|
140
|
-
|
141
|
-
info out of your staging site.
|
139
|
+
description: This gem has been renamed to stage_hand. Find it at [Rubygems.org](https://rubygems.org/gems/stage_hand)
|
140
|
+
or [Gitlab](https://gitlab.com/notch8/stage_hand)
|
142
141
|
email:
|
143
142
|
- rob@notch8.com
|
144
143
|
executables:
|
@@ -162,7 +161,7 @@ files:
|
|
162
161
|
- lib/db_stager.rb
|
163
162
|
- lib/db_stager/cli.rb
|
164
163
|
- lib/db_stager/version.rb
|
165
|
-
homepage: https://gitlab.com/notch8/
|
164
|
+
homepage: https://gitlab.com/notch8/stage_hand
|
166
165
|
licenses:
|
167
166
|
- MIT
|
168
167
|
metadata: {}
|