db-sync 0.0.12 → 0.0.13
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/db/sync.rb +5 -3
- data/lib/db/sync/version.rb +1 -1
- data/lib/tasks/db.rake +6 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db44699a815ff0d136105d6523fb2a72dce02571
|
4
|
+
data.tar.gz: 9500152b296e6499793244837821b2a68109f0a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9bea85c109bc4d70d6c3cf99a4f49a372873a25e96a07e6f12879cadc16f0dabaa938949ab26ea46cfadec0fdf2c3306271584318df849644763225ac225a59
|
7
|
+
data.tar.gz: 1c7638c0f837d435c39e3349d1aad33e53e1a3f3ce545a1941beaeacf053d9c4b6876cec17b29ed0b086af38beedc0ad587b90de7aca39616e3da63bfbba054a
|
data/lib/db/sync.rb
CHANGED
@@ -9,10 +9,11 @@ module Db
|
|
9
9
|
class Sync
|
10
10
|
include ActiveSupport::Configurable
|
11
11
|
|
12
|
-
attr_accessor :sync_dir
|
12
|
+
attr_accessor :sync_dir, :custom_tables
|
13
13
|
|
14
|
-
def initialize(sync_dir = nil)
|
14
|
+
def initialize(sync_dir = nil, tables = nil)
|
15
15
|
self.sync_dir = File.join((Rails.root || '.'), 'db', (sync_dir || 'data'))
|
16
|
+
self.custom_tables = tables
|
16
17
|
end
|
17
18
|
|
18
19
|
def log
|
@@ -34,6 +35,7 @@ module Db
|
|
34
35
|
delete_records(table, diff.deletes, commit)
|
35
36
|
update_records(table, diff.updates, commit)
|
36
37
|
insert_records(table, diff.inserts, commit)
|
38
|
+
# TODO: fix auto increments
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
@@ -112,7 +114,7 @@ module Db
|
|
112
114
|
end
|
113
115
|
|
114
116
|
def working_tables
|
115
|
-
config.tables || all_tables
|
117
|
+
custom_tables || config.tables || all_tables
|
116
118
|
end
|
117
119
|
|
118
120
|
def all_tables
|
data/lib/db/sync/version.rb
CHANGED
data/lib/tasks/db.rake
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
namespace :db do
|
2
2
|
namespace :sync do
|
3
|
-
desc 'Download data from the databse into files.'
|
3
|
+
desc 'Download data from the databse into files. [commit=true/false tables=table1,table2]'
|
4
4
|
task down: :environment do
|
5
|
-
|
5
|
+
tables = ENV['tables'].present? ? ENV['tables'].split(',') : nil
|
6
|
+
synchronizer = Db::Sync.new(sync_dir, tables)
|
6
7
|
synchronizer.sync_down
|
7
8
|
end
|
8
9
|
|
9
|
-
desc 'Upload data from the files into the database.'
|
10
|
+
desc 'Upload data from the files into the database. [commit=true/false tables=table1,table2]'
|
10
11
|
task up: :environment do
|
12
|
+
tables = ENV['tables'].present? ? ENV['tables'].split(',') : nil
|
11
13
|
commit = ENV['commit'].present? ? ENV['commit'] == 'true' : nil
|
12
|
-
synchronizer = Db::Sync.new(sync_dir)
|
14
|
+
synchronizer = Db::Sync.new(sync_dir, tables)
|
13
15
|
sync_up_and_print(synchronizer, commit)
|
14
16
|
if commit.nil? && synchronizer.log.present?
|
15
17
|
print "Commit Changes? [y/n]\n"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasil Joskov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
178
|
version: '0'
|
179
179
|
requirements: []
|
180
180
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
181
|
+
rubygems_version: 2.5.1
|
182
182
|
signing_key:
|
183
183
|
specification_version: 4
|
184
184
|
summary: Database Synchronization Tool
|