myreplicator 1.1.25 → 1.1.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,9 @@ module Myreplicator
10
10
  def self.perform
11
11
  Myreplicator::Log.clear_deads
12
12
  Myreplicator::Log.clear_stucks
13
+ ActiveRecord::Base.configurations.keys.each do |db|
14
+ Myreplicator::VerticaLoader.clean_up_temp_tables(db)
15
+ end
13
16
  end
14
17
 
15
18
  end
@@ -123,7 +123,7 @@ module Myreplicator
123
123
  :filepath => filepath,
124
124
  :destination_schema => @export_obj.destination_schema}
125
125
 
126
- schema_status = MysqlExporter.schema_changed?(options)
126
+ schema_status = Myreplicator::MysqlExporter.schema_changed?(options)
127
127
  Kernel.p "===== schema_status ====="
128
128
  Kernel.p schema_status
129
129
  if schema_status[:changed] # && new?
@@ -162,11 +162,13 @@ module Myreplicator
162
162
  while index < vertica_schema.size
163
163
  # check for column name
164
164
  if vertica_schema.rows[index][:column_name] != mysql_schema[index]["column_name"]
165
+ puts "diff"
165
166
  return true
166
167
  end
167
168
 
168
169
  # check for column's data type
169
170
  if compare_datatypes index, vertica_schema, mysql_schema
171
+ puts "diff #{index}"
170
172
  return true
171
173
  end
172
174
  # and others ?? (PRIMARY, DEFAULT NULL, etc.)
@@ -178,7 +180,7 @@ module Myreplicator
178
180
 
179
181
  def self.compare_datatypes index, vertica_schema, mysql_schema
180
182
  type = Myreplicator::VerticaTypes.convert mysql_schema[index]["data_type"], mysql_schema[index]["column_type"]
181
- if vertica_schema.rows[index][:data_type] != type
183
+ if vertica_schema.rows[index][:data_type].downcase != type.downcase
182
184
  if vertica_schema.rows[index][:data_type] != "timestamp"
183
185
  return true
184
186
  end
@@ -22,6 +22,7 @@ module Myreplicator
22
22
  "mediumtext" => "VARCHAR(65000)",
23
23
  "bit" => "binary",
24
24
  "longtext" => "VARCHAR(65000)",
25
+ "text" => "VARCHAR(65000)",
25
26
  "float" => "decimal"
26
27
  }
27
28
  end
@@ -385,6 +385,28 @@ module Myreplicator
385
385
  # place holder
386
386
  end
387
387
  end
388
+
389
+ def clean_up_temp_tables db
390
+ sql = "SELECT table_name FROm v_catalog.tables WHERE table_schema ='#{db}' and table_name LIKE 'temp_%';"
391
+ result = Myreplicator::DB.exec_sql("vertica",sql)
392
+ result.rows.each do |row|
393
+ tb = row[:table_name]
394
+
395
+ if tb.size > 15
396
+ time_str = tb[(tb.size-15)..(tb.size-1)]
397
+ begin
398
+ time = Time.local(time_str[0..3], time_str[4..5], time_str[6..7], time_str[9..10], time_str[11..12], time_str[13..14])
399
+ rescue Exception => e
400
+ puts e.message
401
+ next
402
+ end
403
+ if time < Time.now() - 1.day
404
+ sql = "DROP TABLE IF EXISTS #{db}.#{tb} CASCADE;"
405
+ Myreplicator::DB.exec_sql("vertica",sql)
406
+ end
407
+ end
408
+ end
409
+ end
388
410
  =begin
389
411
  def create_all_tables db
390
412
  tables = Myreplicator::DB.get_tables(db)
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.1.25"
2
+ VERSION = "1.1.26"
3
3
  end
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.25
4
+ version: 1.1.26
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-05 00:00:00.000000000 Z
12
+ date: 2013-04-08 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: 4333337630484584926
362
+ hash: 2980542232773579979
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: 4333337630484584926
371
+ hash: 2980542232773579979
372
372
  requirements: []
373
373
  rubyforge_project:
374
374
  rubygems_version: 1.8.24