fast_change_table 0.0.2 → 0.0.3
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.
- data/README +5 -0
- data/fast_change_table.gemspec +1 -1
- data/lib/fast_change_table/version.rb +1 -1
- data/lib/fast_change_table.rb +5 -7
- data/test/fast_change_table_test.rb +1 -0
- metadata +8 -6
data/README
ADDED
data/fast_change_table.gemspec
CHANGED
@@ -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
|
|
data/lib/fast_change_table.rb
CHANGED
@@ -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
|
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
|
24
|
-
rescue
|
25
|
-
|
26
|
-
|
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:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
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
|