myreplicator 1.1.30 → 1.1.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -205,7 +205,6 @@ module Myreplicator
205
205
 
206
206
  def set_attributes options
207
207
  options.symbolize_keys!
208
-
209
208
  @export_time = options[:export_time] if options[:export_time]
210
209
  @table = options[:table] if options[:table]
211
210
  @database = options[:database] if options[:database]
@@ -116,8 +116,9 @@ module Myreplicator
116
116
  metadata = options[:metadata]
117
117
  Kernel.p "===== metadata ====="
118
118
  Kernel.p metadata
119
+ Kernel.p "===== metadata.export_type ====="
120
+ Kernel.p metadata.export_type
119
121
  Kernel.p options
120
- #options = {:table => "app_csvs", :destination_schema => "public", :source_schema => "okl_dev"}
121
122
  #options = {:table => "actucast_appeal", :destination_schema => "public", :source_schema => "raw_sources"}
122
123
  schema_check = Myreplicator::MysqlExporter.schema_changed?(:table => options[:table_name],
123
124
  :destination_schema => options[:destination_schema],
@@ -155,15 +156,26 @@ module Myreplicator
155
156
  options[:table] = temp_table
156
157
  Kernel.p "===== COPY TO TEMP TABLE #{temp_table} ====="
157
158
  vertica_copy options
158
- options.reverse_merge!(:temp_table => "#{temp_table}")
159
- options[:table] = options[:table_name]
160
- Kernel.p "===== MERGE ====="
161
- vertica_merge options
162
- #drop the temp table
163
- Kernel.p "===== DROP TEMP TABLE ====="
164
- sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{temp_table} CASCADE;"
165
- #VerticaDb::Base.connection.execute sql
166
- Myreplicator::DB.exec_sql("vertica",sql)
159
+ exp = Export.find(metadata.export_id)
160
+ if exp.export_type == 'incremental'
161
+ options.reverse_merge!(:temp_table => "#{temp_table}")
162
+ options[:table] = options[:table_name]
163
+ Kernel.p "===== MERGE ====="
164
+ vertica_merge options
165
+ #drop the temp table
166
+ Kernel.p "===== DROP TEMP TABLE ====="
167
+ sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{temp_table} CASCADE;"
168
+ Myreplicator::DB.exec_sql("vertica",sql)
169
+ elsif exp.export_type == 'all'
170
+ options.reverse_merge!(:temp_table => "#{temp_table}")
171
+ options[:table] = options[:table_name]
172
+ Kernel.p "===== DROP CURRENT TABLE ====="
173
+ sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{options[:table]} CASCADE;"
174
+ Myreplicator::DB.exec_sql("vertica",sql)
175
+ sql = "ALTER TABLE #{options[:db]}.#{options[:destination_schema]}.#{options[:temp_table]} RENAME TO \"#{options[:table]}\";"
176
+ Kernel.p sql
177
+ Myreplicator::DB.exec_sql("vertica",sql)
178
+ end
167
179
  end
168
180
  end
169
181
 
@@ -315,15 +327,6 @@ module Myreplicator
315
327
  end
316
328
  sql+= "WHEN NOT MATCHED THEN "
317
329
  sql+= "INSERT "
318
- #count = 1
319
- #inserted_columns.each do |col|
320
- # if count < inserted_columns.size
321
- # sql+= "#{col}, "
322
- # else
323
- # sql+= "#{col} "
324
- # end
325
- # count += 1
326
- #end
327
330
  count = 1
328
331
  sql+= " VALUES ("
329
332
  inserted_columns.each do |col|
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.1.30"
2
+ VERSION = "1.1.31"
3
3
  end
@@ -8862,3 +8862,9 @@ Connecting to database specified by database.yml
8862
8862
  Connecting to database specified by database.yml
8863
8863
  Connecting to database specified by database.yml
8864
8864
  Connecting to database specified by database.yml
8865
+ Connecting to database specified by database.yml
8866
+ Connecting to database specified by database.yml
8867
+ Connecting to database specified by database.yml
8868
+ Connecting to database specified by database.yml
8869
+ Connecting to database specified by database.yml
8870
+ Connecting to database specified by database.yml
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.30
4
+ version: 1.1.31
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-04-11 00:00:00.000000000 Z
12
+ date: 2013-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -359,7 +359,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
359
359
  version: '0'
360
360
  segments:
361
361
  - 0
362
- hash: 2380744452726569905
362
+ hash: 3491987006208937872
363
363
  required_rubygems_version: !ruby/object:Gem::Requirement
364
364
  none: false
365
365
  requirements:
@@ -368,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
368
368
  version: '0'
369
369
  segments:
370
370
  - 0
371
- hash: 2380744452726569905
371
+ hash: 3491987006208937872
372
372
  requirements: []
373
373
  rubyforge_project:
374
374
  rubygems_version: 1.8.24