fast_change_table 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,5 @@
1
+ Use fast_change_table instead of change_table in your migrations on large tables of data. Uses a duplication pattern to speed things up.
2
+
3
+ # Known issues
4
+ - Probably only works with MySQL
5
+ - Not tested
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = FastChangeTable::VERSION
8
8
  s.authors = ["Grady Griffin"]
9
9
  s.email = ["gradyg@izea.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/moxie/fast_change_table"
11
11
  s.summary = %q{Faster table changes}
12
12
  s.description = %q{Uses table duplication to speed up migrations on large tables}
13
13
 
@@ -1,3 +1,3 @@
1
1
  module FastChangeTable
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -9,9 +9,8 @@ module FastChangeTable
9
9
  module ClassMethods
10
10
  def fast_change_table(table_name, &block)
11
11
  old_table_name = "old_#{table_name}"
12
- rename_table table_name, old_table_name
12
+ rename_table(table_name, old_table_name)
13
13
  begin
14
- execute "DROP TABLE IF EXISTS #{table_name}"
15
14
  execute "CREATE TABLE #{table_name} LIKE #{old_table_name}"
16
15
  change_table(table_name, &block)
17
16
  #prepare the columns names for the insert statements
@@ -20,11 +19,10 @@ module FastChangeTable
20
19
  common = (current & old).sort
21
20
  columns_to_s = common.collect {|c| "`#{c}`"}.join(',')
22
21
  execute "INSERT INTO #{table_name}(#{columns_to_s}) SELECT #{columns_to_s} FROM #{old_table_name}"
23
- drop_table old_table_name
24
- rescue Exception => e
25
- puts "#{e}\n#{e.backtrace}"
26
- execute "DROP TABLE IF EXISTS #{table_name}"
27
- rename_table old_table_name, table_name
22
+ drop_table(old_table_name)
23
+ rescue
24
+ drop_table(table_name) if table_exists?(table_name)
25
+ rename_table(old_table_name, table_name)
28
26
  end
29
27
  end
30
28
  end
@@ -0,0 +1 @@
1
+ require 'test/unit'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_change_table
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Grady Griffin
@@ -47,12 +47,14 @@ files:
47
47
  - .rvmrc
48
48
  - Gemfile
49
49
  - Gemfile.lock
50
+ - README
50
51
  - Rakefile
51
52
  - fast_change_table.gemspec
52
53
  - lib/fast_change_table.rb
53
54
  - lib/fast_change_table/version.rb
55
+ - test/fast_change_table_test.rb
54
56
  has_rdoc: true
55
- homepage: ""
57
+ homepage: https://github.com/moxie/fast_change_table
56
58
  licenses: []
57
59
 
58
60
  post_install_message:
@@ -85,5 +87,5 @@ rubygems_version: 1.4.2
85
87
  signing_key:
86
88
  specification_version: 3
87
89
  summary: Faster table changes
88
- test_files: []
89
-
90
+ test_files:
91
+ - test/fast_change_table_test.rb