minimum_viable_product 0.0.22 → 0.0.23
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/lib/minimum_viable_product/version.rb +1 -1
- data/lib/tasks/db.rake +70 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79ca64c758ce4600855f92b3a5e43614409c1fe4
|
4
|
+
data.tar.gz: 9afa5a67c65d81e0102ee1f3db227a30392466a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a70fed7ef6ab77614c4025f598511e4c04e8d742fbc7e2f8f672e096b1d0d85bff422b0b1840a35adb1acdd04e7b024c4d30c5709fd21a6755f1ad5b64b993d8
|
7
|
+
data.tar.gz: b53e7e830cc1fb5e19a59c3431508bbfcdf86f7cd627b1d4a1978b5ccf922995d9624a46183aa2e7723cb45b75bf7d75fe9dc3ce2431997d04ca3fb94e361084
|
data/lib/tasks/db.rake
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
def run(cmd, quiet=true)
|
4
|
+
puts "Running #{cmd}" if ENV['DEBUG'] == 'true'
|
5
|
+
command = [cmd]
|
6
|
+
command << "&>/dev/null" if quiet
|
7
|
+
system(command.join(' '))
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :db do
|
11
|
+
desc 'Pull down production database'
|
12
|
+
task :import => ['db:dump:postgres', 'db:import:postgres'] do
|
13
|
+
puts "Done"
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :capture do
|
17
|
+
task :postgres do
|
18
|
+
puts "Capturing Production Backup ..."
|
19
|
+
run("heroku pg:backups capture", false)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
namespace :dump do
|
24
|
+
task :postgres do
|
25
|
+
Rake::Task["db:capture:postgres"].execute if ENV['CAPTURE']
|
26
|
+
puts "Loading Production Dump ..."
|
27
|
+
run("curl -o tmp/latest.dump `heroku pg:backups public-url`")
|
28
|
+
end
|
29
|
+
|
30
|
+
task :clean do
|
31
|
+
run("rm tmp/latest.dump")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
namespace :import do
|
36
|
+
task :postgres => ['kill_postgres_connections','db:drop','db:create'] do
|
37
|
+
config = Rails.configuration.database_configuration
|
38
|
+
host = config[Rails.env]["host"]
|
39
|
+
database = config[Rails.env]["database"]
|
40
|
+
username = config[Rails.env]["username"]
|
41
|
+
password = config[Rails.env]["password"]
|
42
|
+
|
43
|
+
puts "Importing to #{database} ..."
|
44
|
+
|
45
|
+
cmd = ["pg_restore --verbose --clean --no-acl --no-owner"]
|
46
|
+
cmd << "-h #{host}" if host.present?
|
47
|
+
cmd << "-U #{username}" if username.present?
|
48
|
+
cmd << "-p #{password}" if password.present?
|
49
|
+
cmd << "-d #{database}"
|
50
|
+
cmd << "tmp/latest.dump"
|
51
|
+
run(cmd.join(' '))
|
52
|
+
end
|
53
|
+
|
54
|
+
task :kill_postgres_connections => :environment do
|
55
|
+
env = "development"
|
56
|
+
db_config = Rails.configuration.database_configuration[env]
|
57
|
+
fail(ArgumentError, "Could not find db config entry for env (#{env})") unless db_config
|
58
|
+
db_name = db_config['database']
|
59
|
+
|
60
|
+
# thanks to http://stackoverflow.com/questions/12924466/capistrano-with-postgresql-error-database-is-being-accessed-by-other-users
|
61
|
+
# previously, we were kill'ing the postgres processes: http://stackoverflow.com/questions/2369744/rails-postgres-drop-error-database-is-being-accessed-by-other-users
|
62
|
+
cmd = %(psql -c "SELECT pid, pg_terminate_backend(pid) as terminated FROM pg_stat_activity WHERE pid <> pg_backend_pid();" -d '#{db_name}')
|
63
|
+
|
64
|
+
unless run(cmd)
|
65
|
+
fail $?.inspect
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimum_viable_product
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Hunter
|
@@ -494,6 +494,7 @@ files:
|
|
494
494
|
- lib/minimum_viable_product/ext/nil.rb
|
495
495
|
- lib/minimum_viable_product/ext/string.rb
|
496
496
|
- lib/minimum_viable_product/version.rb
|
497
|
+
- lib/tasks/db.rake
|
497
498
|
- lib/tasks/sitemap.rake
|
498
499
|
- test/dummy/README.rdoc
|
499
500
|
- test/dummy/Rakefile
|