myreplicator 1.1.45 → 1.1.46

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.
@@ -88,20 +88,21 @@ module Myreplicator
88
88
 
89
89
  def destination_max_incremental_value
90
90
  sql = SqlCommands.max_value_sql(:incremental_col => self.incremental_column,
91
- :db => self.destination_schema,
92
- :table => self.table_name)
91
+ :max_incremental_value => self.max_incremental_value,
92
+ :db => self.destination_schema,
93
+ :table => self.table_name)
93
94
  puts sql
94
95
  if self.export_to == 'vertica'
95
96
  begin
96
97
  result = Myreplicator::DB.exec_sql('vertica',sql)
97
- if result.rows.first[:max].blank?
98
+ if result.rows.first[:COALESCE].blank?
98
99
  return "0"
99
100
  else
100
- case result.rows.first[:max].class.to_s
101
+ case result.rows.first[:COALESCE].class.to_s
101
102
  when "DateTime"
102
- return result.rows.first[:max].strftime('%Y-%m-%d %H:%M:%S')
103
+ return result.rows.first[:COALESCE].strftime('%Y-%m-%d %H:%M:%S')
103
104
  else
104
- return result.rows.first[:max].to_s
105
+ return result.rows.first[:COALESCE].to_s
105
106
  end
106
107
  end
107
108
  rescue Exception => e
@@ -125,18 +126,20 @@ module Myreplicator
125
126
 
126
127
  def max_value
127
128
  sql = SqlCommands.max_value_sql(:incremental_col => self.incremental_column,
129
+ :max_incremental_value => self.max_incremental_value,
128
130
  :db => self.source_schema,
129
131
  :table => self.table_name)
130
132
  result = exec_on_source(sql)
131
133
  if result.first.nil?
132
134
  return ""
133
135
  else
134
- case result.first.first.class.to_s
135
- when "Symbol", "Fixnum"
136
- return result.first.first.to_s
137
- else
138
- return result.first.first.to_s(:db)
139
- end
136
+ #case result.first.first.class.to_s
137
+ #when "Symbol", "Fixnum"
138
+ # return result.first.first.to_s
139
+ #else
140
+ # return result.first.first.to_s(:db)
141
+ #end
142
+ return result.first.first
140
143
  end
141
144
  end
142
145
 
@@ -237,7 +237,7 @@ module Myreplicator
237
237
  sql = ""
238
238
 
239
239
  if options[:incremental_col]
240
- sql = "SELECT max(#{options[:incremental_col]}) FROM #{options[:db]}.#{options[:table]}"
240
+ sql = "SELECT COALESCE(max(#{options[:incremental_col]}),'#{options[:max_incremental_value]}') FROM #{options[:db]}.#{options[:table]}"
241
241
  else
242
242
  raise Myreplicator::Exceptions::MissingArgs.new("Missing Incremental Column Parameter")
243
243
  end
data/lib/loader/loader.rb CHANGED
@@ -230,7 +230,7 @@ module Myreplicator
230
230
  # Uses the values specified in the metadatta object
231
231
  ##
232
232
  def self.incremental_load metadata
233
- exp = Export.find(metadata.export_id)
233
+ exp = Myreplicator::Export.find(metadata.export_id)
234
234
  #Loader.unzip(metadata.filename)
235
235
  #metadata.zipped = false
236
236
 
@@ -167,11 +167,11 @@ module Myreplicator
167
167
  # run the export. The next time loader runs, it will load the file
168
168
  exp.export
169
169
  else # incremental load
170
- temp_table = create_temp_table ops
170
+ temp_table = Myreplicator::VerticaLoader.create_temp_table ops
171
171
  options[:table] = temp_table
172
172
  Kernel.p "===== COPY TO TEMP TABLE #{temp_table} ====="
173
- vertica_copy options
174
- options.reverse_merge!(:temp_table => "#{temp_table}")
173
+ Myreplicator::VerticaLoader.vertica_copy options
174
+ options[:temp_table] = "#{temp_table}"
175
175
  options[:table] = options[:table_name]
176
176
  sql = "SELECT COUNT(*) FROM #{options[:db]}.#{options[:destination_schema]}.#{options[:temp_table]};"
177
177
  result = Myreplicator::DB.exec_sql("vertica",sql)
@@ -193,7 +193,7 @@ module Myreplicator
193
193
  Myreplicator::VerticaUtils.set_grants(grants)
194
194
  elsif exp.export_type == 'incremental'
195
195
  Kernel.p "===== MERGE ====="
196
- vertica_merge options
196
+ Myreplicator::VerticaLoader.vertica_merge options
197
197
  #drop the temp table
198
198
  Kernel.p "===== DROP TEMP TABLE ====="
199
199
  sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{temp_table} CASCADE;"
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.1.45"
2
+ VERSION = "1.1.46"
3
3
  end
@@ -8,9 +8,12 @@ namespace :maintenance do
8
8
  Resque.remove_schedule(export.schedule_name)
9
9
  end
10
10
 
11
+ sql ="SELECT CLOSE_ALL_SESSIONS();"
12
+ Myreplicator::DB.exec_sql("vertica",sql)
13
+
11
14
  Resque.remove_schedule("myreplicator_loader")
12
15
  Resque.remove_schedule("myreplicator_sweeper")
13
- Resque.remove_schedule("myreplicator_transporter")
16
+ Resque.remove_schedule("myreplicator_transporter")
14
17
  end
15
18
 
16
19
  task :start_dr_jobs do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myreplicator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.45
4
+ version: 1.1.46
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -328,7 +328,6 @@ files:
328
328
  - test/dummy/tmp/cache/assets/E2D/2C0/sprockets%2Ff0c2e561abf62fabc69462c2cfeef3d8
329
329
  - test/dummy/tmp/cache/assets/E76/790/sprockets%2Fdaf734b1fcabd6ca66b333ad0f0fdbf0
330
330
  - test/dummy/tmp/cache/assets/F08/560/sprockets%2F5ab2cf5fb087fdef95cfe9fe6fabf9df
331
- - test/dummy/tmp/pids/server.pid
332
331
  - test/fixtures/myreplicator/exports.yml
333
332
  - test/functional/myreplicator/exports_controller_test.rb
334
333
  - test/integration/navigation_test.rb
@@ -353,7 +352,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
353
352
  version: '0'
354
353
  segments:
355
354
  - 0
356
- hash: 2156921709452329403
355
+ hash: 3606855221214584877
357
356
  required_rubygems_version: !ruby/object:Gem::Requirement
358
357
  none: false
359
358
  requirements:
@@ -362,7 +361,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
361
  version: '0'
363
362
  segments:
364
363
  - 0
365
- hash: 2156921709452329403
364
+ hash: 3606855221214584877
366
365
  requirements: []
367
366
  rubyforge_project:
368
367
  rubygems_version: 1.8.24
@@ -458,7 +457,6 @@ test_files:
458
457
  - test/dummy/tmp/cache/assets/E2D/2C0/sprockets%2Ff0c2e561abf62fabc69462c2cfeef3d8
459
458
  - test/dummy/tmp/cache/assets/E76/790/sprockets%2Fdaf734b1fcabd6ca66b333ad0f0fdbf0
460
459
  - test/dummy/tmp/cache/assets/F08/560/sprockets%2F5ab2cf5fb087fdef95cfe9fe6fabf9df
461
- - test/dummy/tmp/pids/server.pid
462
460
  - test/fixtures/myreplicator/exports.yml
463
461
  - test/functional/myreplicator/exports_controller_test.rb
464
462
  - test/integration/navigation_test.rb
@@ -1 +0,0 @@
1
- 17877