db_stager 0.1.1 → 0.2.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/lib/db_stager/cli.rb +15 -11
- data/lib/db_stager/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5596cc698905e2cb5c03fbcebee2a272403360f4
|
|
4
|
+
data.tar.gz: 2e27f20781268cc10f257c000cec3307d8b043cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ecd312cb600acc15779f8336443da10cd65997fd80a18a08744a5d3f0d7a88fde9aa99c253d972b128ab7779633b44b29654d2ca1830eefb44d69865cd9c3226
|
|
7
|
+
data.tar.gz: 9acec0d9ffaf4eaff6dcbd7b034b00828a93c0c31e2c2a1a8b53f3b24cd629dcf213b0e8af4efad56c93c0dc2ea65d015d52a932e07a46627bc6ae4601e668a6
|
data/Gemfile.lock
CHANGED
data/lib/db_stager/cli.rb
CHANGED
|
@@ -23,14 +23,10 @@ module DbStager
|
|
|
23
23
|
def capture(dir=".")
|
|
24
24
|
Dir.chdir(dir)
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
# Get connection info
|
|
28
|
-
|
|
29
|
-
db = Sequel.connect(YAML.load(ERB.new(File.read(File.join(Dir.pwd, 'config', 'database.yml'))).result)[environment])
|
|
26
|
+
sh 'rake db:structure:dump'
|
|
30
27
|
|
|
31
28
|
capture_file = options[:file] || File.join(Dir.pwd, "db", "#{environment}_capture.sql")
|
|
32
29
|
File.open(capture_file, "w") do |file|
|
|
33
|
-
|
|
34
30
|
db.tables.each do |table_name|
|
|
35
31
|
items = db[table_name]
|
|
36
32
|
items.each do |item|
|
|
@@ -45,17 +41,25 @@ module DbStager
|
|
|
45
41
|
desc "upload", "upload your most recent capture to S3"
|
|
46
42
|
desc "download", "download your most recent capture from S3"
|
|
47
43
|
|
|
44
|
+
method_option :environment, type: :string, aliases: '-e'
|
|
45
|
+
method_option :structure_file, type: :string, aliases: '-s'
|
|
46
|
+
method_option :file, type: :string, aliases: '-f'
|
|
48
47
|
desc "load", "overwrite the current db with the most recently downloaded stager db"
|
|
49
48
|
def load(dir=".")
|
|
50
49
|
Dir.chdir(dir)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# Get connection info
|
|
54
|
-
|
|
55
|
-
db = Sequel.connect(YAML.load(ERB.new(File.read(File.join(Dir.pwd, 'config', 'database.yml'))).result)[environment])
|
|
56
|
-
|
|
50
|
+
structure_file = options[:structure_file] || File.join(Dir.pwd, "db", "structure.sql")
|
|
51
|
+
db.run File.read(struture_file)
|
|
57
52
|
capture_file = options[:file] || File.join(Dir.pwd, "db", "#{environment}_capture.sql")
|
|
58
53
|
db.run File.read(capture_file)
|
|
59
54
|
end
|
|
60
55
|
end
|
|
56
|
+
|
|
57
|
+
protected
|
|
58
|
+
def environment
|
|
59
|
+
@environment ||= options[:environment] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def db
|
|
63
|
+
@db ||= Sequel.connect(YAML.load(ERB.new(File.read(File.join(Dir.pwd, 'config', 'database.yml'))).result)[environment])
|
|
64
|
+
end
|
|
61
65
|
end
|
data/lib/db_stager/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: db_stager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rob Kaufman
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-08-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|