fast_change_table 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +7 -7
- data/README.md +4 -2
- data/lib/fast_change_table/fast_change_table.rb +12 -4
- data/lib/fast_change_table/version.rb +1 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fast_change_table (1.
|
4
|
+
fast_change_table (1.3.0)
|
5
5
|
activerecord (>= 2.3)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.2.
|
11
|
-
activesupport (= 3.2.
|
10
|
+
activemodel (3.2.1)
|
11
|
+
activesupport (= 3.2.1)
|
12
12
|
builder (~> 3.0.0)
|
13
|
-
activerecord (3.2.
|
14
|
-
activemodel (= 3.2.
|
15
|
-
activesupport (= 3.2.
|
13
|
+
activerecord (3.2.1)
|
14
|
+
activemodel (= 3.2.1)
|
15
|
+
activesupport (= 3.2.1)
|
16
16
|
arel (~> 3.0.0)
|
17
17
|
tzinfo (~> 0.3.29)
|
18
|
-
activesupport (3.2.
|
18
|
+
activesupport (3.2.1)
|
19
19
|
i18n (~> 0.6)
|
20
20
|
multi_json (~> 1.0)
|
21
21
|
arel (3.0.0)
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Use fast\_change\_table instead of change_table in your migrations on large tabl
|
|
4
4
|
|
5
5
|
__Known issues:__
|
6
6
|
|
7
|
-
* Currently fast\_change\_table
|
7
|
+
* Currently fast\_change\_table transformations do not support Rails 3 reversible migration method.
|
8
8
|
|
9
9
|
|
10
10
|
__Usage:__
|
@@ -12,7 +12,9 @@ __Usage:__
|
|
12
12
|
uses ordinary change_table syntax but adds two options
|
13
13
|
|
14
14
|
* "replace\_keys" to remove all indexes; new indexes will be specified
|
15
|
-
- "disable\_keys" to remove indexes and apply them after data load; this is a tremendous performance enhancement for a dbms with fast index creation; it is active by default. set it to false to prevent its
|
15
|
+
- "disable\_keys" to remove indexes and apply them after data load; this is a tremendous performance enhancement for a dbms with fast index creation; it is active by default. set it to false to prevent its usage
|
16
|
+
|
17
|
+
the bulk option is set by default set it to false to prevent its usage.
|
16
18
|
|
17
19
|
__Example:__
|
18
20
|
|
@@ -7,7 +7,7 @@ module FastChangeTable
|
|
7
7
|
rename_table(table_name, old_table_name)
|
8
8
|
begin
|
9
9
|
create_table_like(old_table_name, table_name, options)
|
10
|
-
renamed_columns = change_table_with_remaps(table_name, &block)
|
10
|
+
renamed_columns = change_table_with_remaps(table_name, options, &block)
|
11
11
|
index_list = options[:disable_keys] == false ? [] : disable_indexes(table_name)
|
12
12
|
#prepare the columns names for the insert statements
|
13
13
|
copy_table(old_table_name, table_name, renamed_columns)
|
@@ -21,9 +21,17 @@ module FastChangeTable
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def change_table_with_remaps(table_name)
|
25
|
-
|
26
|
-
|
24
|
+
def change_table_with_remaps(table_name, options = {})
|
25
|
+
options.reverse_merge!(:bulk => true)
|
26
|
+
if respond_to?('supports_bulk_alter?') && supports_bulk_alter? && options[:bulk]
|
27
|
+
recorder = ActiveRecord::Migration::CommandRecorder.new(self)
|
28
|
+
t = ActiveRecord::ConnectionAdapters::Table.new(table_name, recorder)
|
29
|
+
yield t
|
30
|
+
bulk_change_table(table_name, recorder.commands)
|
31
|
+
else
|
32
|
+
t = ActiveRecord::ConnectionAdapters::Table.new(table_name, self)
|
33
|
+
yield t
|
34
|
+
end
|
27
35
|
return t.renamed_columns
|
28
36
|
end
|
29
37
|
|
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: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Grady Griffin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02-
|
18
|
+
date: 2012-02-07 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|