capistrano-db-tasks 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.markdown +92 -82
- data/lib/capistrano-db-tasks/database.rb +178 -149
- data/lib/capistrano-db-tasks/dbtasks.rb +120 -102
- data/lib/capistrano-db-tasks/version.rb +1 -1
- metadata +9 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea446d397b392606dc52f06573bcb96a9393512c
|
4
|
+
data.tar.gz: 5f7e0c4afe2bbabe318dbc4394f89ef785b48dfd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 176d858ac97f2e33fd31457e178c1e34c33d9022594bf83f2cb81b1dd4253ce665782c4f5eaaef36ff263c9b2ee3cd0b4dc4c5229ea7417d48d1cc57215c8426
|
7
|
+
data.tar.gz: c850f2dd9138ba36f5cb07506eb67c0f6b6feda66f5daef31d2edccaf71fec8ac9990d199ef03113e311f1811102330079a13a2112d0a434f0edb0812ff683f3
|
data/README.markdown
CHANGED
@@ -1,82 +1,92 @@
|
|
1
|
-
CapistranoDbTasks
|
2
|
-
=================
|
3
|
-
|
4
|
-
Add database AND assets tasks to capistrano to a Rails project.
|
5
|
-
It only works with capistrano 3. Older versions until 0.3 works with capistrano 2.
|
6
|
-
|
7
|
-
Currently
|
8
|
-
|
9
|
-
* It only supports mysql and postgresql (both side remote and local)
|
10
|
-
* Synchronize assets remote to local and local to remote
|
11
|
-
|
12
|
-
Commands mysql, mysqldump (or pg_dump, psql), bzip2 and unbzip2 must be in your PATH
|
13
|
-
|
14
|
-
Feel free to fork and to add more database support or new tasks.
|
15
|
-
|
16
|
-
Install
|
17
|
-
=======
|
18
|
-
|
19
|
-
Add it as a gem:
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
gem "capistrano-db-tasks", require: false
|
23
|
-
```
|
24
|
-
|
25
|
-
Add to config/deploy.rb:
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
require 'capistrano-db-tasks'
|
29
|
-
|
30
|
-
# if you haven't already specified
|
31
|
-
set :rails_env, "production"
|
32
|
-
|
33
|
-
# if you want to remove the dump file after loading
|
34
|
-
set :db_local_clean, true
|
35
|
-
|
36
|
-
#
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
set :
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
1
|
+
CapistranoDbTasks
|
2
|
+
=================
|
3
|
+
|
4
|
+
Add database AND assets tasks to capistrano to a Rails project.
|
5
|
+
It only works with capistrano 3. Older versions until 0.3 works with capistrano 2.
|
6
|
+
|
7
|
+
Currently
|
8
|
+
|
9
|
+
* It only supports mysql and postgresql (both side remote and local)
|
10
|
+
* Synchronize assets remote to local and local to remote
|
11
|
+
|
12
|
+
Commands mysql, mysqldump (or pg_dump, psql), bzip2 and unbzip2 must be in your PATH
|
13
|
+
|
14
|
+
Feel free to fork and to add more database support or new tasks.
|
15
|
+
|
16
|
+
Install
|
17
|
+
=======
|
18
|
+
|
19
|
+
Add it as a gem:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem "capistrano-db-tasks", require: false
|
23
|
+
```
|
24
|
+
|
25
|
+
Add to config/deploy.rb:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'capistrano-db-tasks'
|
29
|
+
|
30
|
+
# if you haven't already specified
|
31
|
+
set :rails_env, "production"
|
32
|
+
|
33
|
+
# if you want to remove the local dump file after loading
|
34
|
+
set :db_local_clean, true
|
35
|
+
|
36
|
+
# if you want to remove the dump file from the server after downloading
|
37
|
+
set :db_remote_clean, true
|
38
|
+
|
39
|
+
# If you want to import assets, you can change default asset dir (default = system)
|
40
|
+
# This directory must be in your shared directory on the server
|
41
|
+
set :assets_dir, %w(public/assets public/att)
|
42
|
+
set :local_assets_dir, %w(public/assets public/att)
|
43
|
+
|
44
|
+
# if you want to work on a specific local environment (default = ENV['RAILS_ENV'] || 'development')
|
45
|
+
set :locals_rails_env, "production"
|
46
|
+
|
47
|
+
# if you are highly paranoid and want to prevent any push operation to the server
|
48
|
+
set :disallow_pushing, true
|
49
|
+
```
|
50
|
+
|
51
|
+
Add to .gitignore
|
52
|
+
```yml
|
53
|
+
/db/*.sql
|
54
|
+
```
|
55
|
+
|
56
|
+
|
57
|
+
[How to install bzip2 on Windows](http://stackoverflow.com/a/25625988/3324219)
|
58
|
+
|
59
|
+
Available tasks
|
60
|
+
===============
|
61
|
+
|
62
|
+
app:local:sync || app:pull # Synchronize your local assets AND database using remote assets and database
|
63
|
+
app:remote:sync || app:push # Synchronize your remote assets AND database using local assets and database
|
64
|
+
|
65
|
+
assets:local:sync || assets:pull # Synchronize your local assets using remote assets
|
66
|
+
assets:remote:sync || assets:push # Synchronize your remote assets using local assets
|
67
|
+
|
68
|
+
db:local:sync || db:pull # Synchronize your local database using remote database data
|
69
|
+
db:remote:sync || db:push # Synchronize your remote database using local database data
|
70
|
+
|
71
|
+
Example
|
72
|
+
=======
|
73
|
+
|
74
|
+
cap db:pull
|
75
|
+
cap production db:pull # if you are using capistrano-ext to have multistages
|
76
|
+
|
77
|
+
|
78
|
+
Contributors
|
79
|
+
============
|
80
|
+
|
81
|
+
* tilsammans (http://github.com/tilsammansee)
|
82
|
+
* bigfive (http://github.com/bigfive)
|
83
|
+
* jakemauer (http://github.com/jakemauer)
|
84
|
+
* tjoneseng (http://github.com/tjoneseng)
|
85
|
+
|
86
|
+
TODO
|
87
|
+
====
|
88
|
+
|
89
|
+
* May be change project's name as it's not only database tasks now :)
|
90
|
+
* Add tests
|
91
|
+
|
92
|
+
Copyright (c) 2009 [Sébastien Gruhier - XILINUS], released under the MIT license
|
@@ -1,149 +1,178 @@
|
|
1
|
-
module Database
|
2
|
-
class Base
|
3
|
-
attr_accessor :config, :output_file
|
4
|
-
def initialize(cap_instance)
|
5
|
-
@cap = cap_instance
|
6
|
-
end
|
7
|
-
|
8
|
-
def mysql?
|
9
|
-
@config['adapter'] =~ /^mysql/
|
10
|
-
end
|
11
|
-
|
12
|
-
def postgresql?
|
13
|
-
%w(postgresql pg).include? @config['adapter']
|
14
|
-
end
|
15
|
-
|
16
|
-
def credentials
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
def
|
74
|
-
|
75
|
-
@cap.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
def
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
end
|
1
|
+
module Database
|
2
|
+
class Base
|
3
|
+
attr_accessor :config, :output_file
|
4
|
+
def initialize(cap_instance)
|
5
|
+
@cap = cap_instance
|
6
|
+
end
|
7
|
+
|
8
|
+
def mysql?
|
9
|
+
@config['adapter'] =~ /^mysql/
|
10
|
+
end
|
11
|
+
|
12
|
+
def postgresql?
|
13
|
+
%w(postgresql pg).include? @config['adapter']
|
14
|
+
end
|
15
|
+
|
16
|
+
def credentials
|
17
|
+
credential_params = ""
|
18
|
+
username = @config['username'] || @config['user']
|
19
|
+
|
20
|
+
if mysql?
|
21
|
+
credential_params << " -u #{username} " if username
|
22
|
+
credential_params << " -p'#{@config['password']}' " if @config['password']
|
23
|
+
credential_params << " -h #{@config['host']} " if @config['host']
|
24
|
+
credential_params << " -S #{@config['socket']} " if @config['socket']
|
25
|
+
credential_params << " -P #{@config['port']} " if @config['port']
|
26
|
+
elsif postgresql?
|
27
|
+
credential_params << " -U #{username} " if username
|
28
|
+
credential_params << " -h #{@config['host']} " if @config['host']
|
29
|
+
credential_params << " -p #{@config['port']} " if @config['port']
|
30
|
+
end
|
31
|
+
|
32
|
+
credential_params
|
33
|
+
end
|
34
|
+
|
35
|
+
def database
|
36
|
+
@config['database']
|
37
|
+
end
|
38
|
+
|
39
|
+
def current_time
|
40
|
+
Time.now.strftime("%Y-%m-%d-%H%M%S")
|
41
|
+
end
|
42
|
+
|
43
|
+
def output_file
|
44
|
+
@output_file ||= "db/#{database}_#{current_time}.sql.bz2"
|
45
|
+
end
|
46
|
+
|
47
|
+
def pgpass
|
48
|
+
"PGPASSWORD='#{@config['password']}'" if @config['password']
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def dump_cmd
|
54
|
+
if mysql?
|
55
|
+
"mysqldump #{credentials} #{database} --lock-tables=false"
|
56
|
+
elsif postgresql?
|
57
|
+
"#{pgpass} pg_dump --no-acl --no-owner #{credentials} #{database}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def import_cmd(file)
|
62
|
+
if mysql?
|
63
|
+
"mysql #{credentials} -D #{database} < #{file}"
|
64
|
+
elsif postgresql?
|
65
|
+
terminate_connection_sql = "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '#{database}' AND pid <> pg_backend_pid();"
|
66
|
+
"#{pgpass} psql -c \"#{terminate_connection_sql};\" #{credentials}; #{pgpass} dropdb #{credentials} #{database}; #{pgpass} createdb #{credentials} #{database}; #{pgpass} psql #{credentials} -d #{database} < #{file}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
class Remote < Base
|
73
|
+
def initialize(cap_instance)
|
74
|
+
super(cap_instance)
|
75
|
+
@config = @cap.capture("cat #{@cap.current_path}/config/database.yml")
|
76
|
+
@config = YAML.load(ERB.new(@config).result)[@cap.fetch(:rails_env).to_s]
|
77
|
+
end
|
78
|
+
|
79
|
+
def dump
|
80
|
+
@cap.execute "cd #{@cap.current_path} && #{dump_cmd} | bzip2 - - > #{output_file}"
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
84
|
+
def download(local_file = "#{output_file}")
|
85
|
+
@cap.download! dump_file_path, local_file
|
86
|
+
end
|
87
|
+
|
88
|
+
def clean_dump_if_needed
|
89
|
+
if @cap.fetch(:db_remote_clean)
|
90
|
+
@cap.execute "rm -f #{dump_file_path}"
|
91
|
+
else
|
92
|
+
@cap.info "leaving #{dump_file_path} on the server (add \"set :db_remote_clean, true\" to deploy.rb to remove)"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# cleanup = true removes the mysqldump file after loading, false leaves it in db/
|
97
|
+
def load(file, cleanup)
|
98
|
+
unzip_file = File.join(File.dirname(file), File.basename(file, '.bz2'))
|
99
|
+
# @cap.run "cd #{@cap.current_path} && bunzip2 -f #{file} && RAILS_ENV=#{@cap.rails_env} bundle exec rake db:drop db:create && #{import_cmd(unzip_file)}"
|
100
|
+
@cap.execute "cd #{@cap.current_path} && bunzip2 -f #{file} && RAILS_ENV=#{@cap.fetch(:rails_env)} && #{import_cmd(unzip_file)}"
|
101
|
+
@cap.execute("cd #{@cap.current_path} && rm #{unzip_file}") if cleanup
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def dump_file_path
|
107
|
+
"#{@cap.current_path}/#{output_file}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class Local < Base
|
112
|
+
def initialize(cap_instance)
|
113
|
+
super(cap_instance)
|
114
|
+
@config = YAML.load(ERB.new(File.read(File.join('config', 'database.yml'))).result)[fetch(:local_rails_env).to_s]
|
115
|
+
puts "local #{@config}"
|
116
|
+
end
|
117
|
+
|
118
|
+
# cleanup = true removes the mysqldump file after loading, false leaves it in db/
|
119
|
+
def load(file, cleanup)
|
120
|
+
unzip_file = File.join(File.dirname(file), File.basename(file, '.bz2'))
|
121
|
+
# system("bunzip2 -f #{file} && bundle exec rake db:drop db:create && #{import_cmd(unzip_file)} && bundle exec rake db:migrate")
|
122
|
+
@cap.info "executing local: bunzip2 -f #{file} && #{import_cmd(unzip_file)}"
|
123
|
+
system("bunzip2 -f #{file} && #{import_cmd(unzip_file)}")
|
124
|
+
if cleanup
|
125
|
+
@cap.info "removing #{unzip_file}"
|
126
|
+
File.unlink(unzip_file)
|
127
|
+
else
|
128
|
+
@cap.info "leaving #{unzip_file} (specify :db_local_clean in deploy.rb to remove)"
|
129
|
+
end
|
130
|
+
@cap.info "Completed database import"
|
131
|
+
end
|
132
|
+
|
133
|
+
def dump
|
134
|
+
system "#{dump_cmd} | bzip2 - - > #{output_file}"
|
135
|
+
self
|
136
|
+
end
|
137
|
+
|
138
|
+
def upload
|
139
|
+
remote_file = "#{@cap.current_path}/#{output_file}"
|
140
|
+
@cap.upload! output_file, remote_file
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
class << self
|
146
|
+
def check(local_db, remote_db)
|
147
|
+
unless (local_db.mysql? && remote_db.mysql?) || (local_db.postgresql? && remote_db.postgresql?)
|
148
|
+
raise 'Only mysql or postgresql on remote and local server is supported'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def remote_to_local(instance)
|
153
|
+
local_db = Database::Local.new(instance)
|
154
|
+
remote_db = Database::Remote.new(instance)
|
155
|
+
|
156
|
+
check(local_db, remote_db)
|
157
|
+
|
158
|
+
begin
|
159
|
+
remote_db.dump.download
|
160
|
+
ensure
|
161
|
+
remote_db.clean_dump_if_needed
|
162
|
+
end
|
163
|
+
local_db.load(remote_db.output_file, instance.fetch(:db_local_clean))
|
164
|
+
end
|
165
|
+
|
166
|
+
def local_to_remote(instance)
|
167
|
+
local_db = Database::Local.new(instance)
|
168
|
+
remote_db = Database::Remote.new(instance)
|
169
|
+
|
170
|
+
check(local_db, remote_db)
|
171
|
+
|
172
|
+
local_db.dump.upload
|
173
|
+
remote_db.load(local_db.output_file, instance.fetch(:db_local_clean))
|
174
|
+
File.unlink(local_db.output_file) if instance.fetch(:db_local_clean)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
@@ -1,102 +1,120 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/util")
|
2
|
-
require File.expand_path("#{File.dirname(__FILE__)}/database")
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/asset")
|
4
|
-
|
5
|
-
set :local_rails_env, ENV['RAILS_ENV'] || 'development' unless fetch(:local_rails_env)
|
6
|
-
set :rails_env, 'production' unless fetch(:rails_env)
|
7
|
-
set :db_local_clean, false unless fetch(:db_local_clean)
|
8
|
-
set :assets_dir, 'system' unless fetch(:assets_dir)
|
9
|
-
set :local_assets_dir, 'public' unless fetch(:local_assets_dir)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/util")
|
2
|
+
require File.expand_path("#{File.dirname(__FILE__)}/database")
|
3
|
+
require File.expand_path("#{File.dirname(__FILE__)}/asset")
|
4
|
+
|
5
|
+
set :local_rails_env, ENV['RAILS_ENV'] || 'development' unless fetch(:local_rails_env)
|
6
|
+
set :rails_env, fetch(:stage) || 'production' unless fetch(:rails_env)
|
7
|
+
set :db_local_clean, false unless fetch(:db_local_clean)
|
8
|
+
set :assets_dir, 'system' unless fetch(:assets_dir)
|
9
|
+
set :local_assets_dir, 'public' unless fetch(:local_assets_dir)
|
10
|
+
set :skip_data_sync_confirm, (ENV['SKIP_DATA_SYNC_CONFIRM'].to_s.downcase == 'true')
|
11
|
+
set :disallow_pushing, false unless fetch(:disallow_pushing)
|
12
|
+
|
13
|
+
namespace :capistrano_db_tasks do
|
14
|
+
task :check_can_push do
|
15
|
+
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :db do
|
20
|
+
namespace :remote do
|
21
|
+
desc 'Synchronize your remote database using local database data'
|
22
|
+
task :sync => 'capistrano_db_tasks:check_can_push' do
|
23
|
+
on roles(:db) do
|
24
|
+
if fetch(:skip_data_sync_confirm) || Util.prompt('Are you sure you want to REPLACE THE REMOTE DATABASE with local database')
|
25
|
+
Database.local_to_remote(self)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
namespace :local do
|
32
|
+
desc 'Synchronize your local database using remote database data'
|
33
|
+
task :sync do
|
34
|
+
on roles(:db) do
|
35
|
+
puts "Local database: #{Database::Local.new(self).database}"
|
36
|
+
if fetch(:skip_data_sync_confirm) || Util.prompt('Are you sure you want to erase your local database with server database')
|
37
|
+
Database.remote_to_local(self)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Synchronize your local database using remote database data'
|
44
|
+
task :pull => "db:local:sync"
|
45
|
+
|
46
|
+
desc 'Synchronize your remote database using local database data'
|
47
|
+
task :push => "db:remote:sync"
|
48
|
+
end
|
49
|
+
|
50
|
+
namespace :assets do
|
51
|
+
namespace :remote do
|
52
|
+
desc 'Synchronize your remote assets using local assets'
|
53
|
+
task :sync => 'capistrano_db_tasks:check_can_push' do
|
54
|
+
on roles(:app) do
|
55
|
+
puts "Assets directories: #{fetch(:assets_dir)}"
|
56
|
+
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to erase your server assets with local assets")
|
57
|
+
Asset.local_to_remote(self)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
namespace :local do
|
64
|
+
desc 'Synchronize your local assets using remote assets'
|
65
|
+
task :sync do
|
66
|
+
on roles(:app) do
|
67
|
+
puts "Assets directories: #{fetch(:local_assets_dir)}"
|
68
|
+
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to erase your local assets with server assets")
|
69
|
+
Asset.remote_to_local(self)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'Synchronize your local assets using remote assets'
|
76
|
+
task :pull => "assets:local:sync"
|
77
|
+
|
78
|
+
desc 'Synchronize your remote assets using local assets'
|
79
|
+
task :push => "assets:remote:sync"
|
80
|
+
end
|
81
|
+
|
82
|
+
namespace :app do
|
83
|
+
namespace :remote do
|
84
|
+
desc 'Synchronize your remote assets AND database using local assets and database'
|
85
|
+
task :sync => 'capistrano_db_tasks:check_can_push' do
|
86
|
+
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to REPLACE THE REMOTE DATABASE AND your remote assets with local database and assets(#{fetch(:assets_dir)})")
|
87
|
+
on roles(:db) do
|
88
|
+
Database.local_to_remote(self)
|
89
|
+
end
|
90
|
+
|
91
|
+
on roles(:app) do
|
92
|
+
Asset.local_to_remote(self)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
namespace :local do
|
99
|
+
desc 'Synchronize your local assets AND database using remote assets and database'
|
100
|
+
task :sync do
|
101
|
+
puts "Local database : #{Database::Local.new(self).database}"
|
102
|
+
puts "Assets directories : #{fetch(:local_assets_dir)}"
|
103
|
+
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to erase your local database AND your local assets with server database and assets(#{fetch(:assets_dir)})")
|
104
|
+
on roles(:db) do
|
105
|
+
Database.remote_to_local(self)
|
106
|
+
end
|
107
|
+
|
108
|
+
on roles(:app) do
|
109
|
+
Asset.remote_to_local(self)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
desc 'Synchronize your local assets AND database using remote assets and database'
|
116
|
+
task :pull => "app:local:sync"
|
117
|
+
|
118
|
+
desc 'Synchronize your remote assets AND database using local assets and database'
|
119
|
+
task :push => "app:remote:sync"
|
120
|
+
end
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-db-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
5
|
-
prerelease:
|
4
|
+
version: '0.4'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sebastien Gruhier
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capistrano
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.0.0
|
30
27
|
description: A collection of capistrano tasks for syncing assets and databases
|
@@ -49,33 +46,26 @@ files:
|
|
49
46
|
- test/test_helper.rb
|
50
47
|
homepage: https://github.com/sgruhier/capistrano-db-tasks
|
51
48
|
licenses: []
|
49
|
+
metadata: {}
|
52
50
|
post_install_message:
|
53
51
|
rdoc_options: []
|
54
52
|
require_paths:
|
55
53
|
- lib
|
56
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
55
|
requirements:
|
59
|
-
- -
|
56
|
+
- - ">="
|
60
57
|
- !ruby/object:Gem::Version
|
61
58
|
version: '0'
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
hash: 2376160182580984421
|
65
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
60
|
requirements:
|
68
|
-
- -
|
61
|
+
- - ">="
|
69
62
|
- !ruby/object:Gem::Version
|
70
63
|
version: '0'
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
hash: 2376160182580984421
|
74
64
|
requirements: []
|
75
65
|
rubyforge_project: capistrano-db-tasks
|
76
|
-
rubygems_version:
|
66
|
+
rubygems_version: 2.2.2
|
77
67
|
signing_key:
|
78
|
-
specification_version:
|
68
|
+
specification_version: 4
|
79
69
|
summary: A collection of capistrano tasks for syncing assets and databases
|
80
70
|
test_files:
|
81
71
|
- test/capistrano_db_tasks_test.rb
|