mysql_online_migrations 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +25 -17
- data/lib/mysql_online_migrations.rb +17 -1
- data/mysql_online_migrations.gemspec +1 -1
- data/spec/lib/mysql_online_migrations_spec.rb +28 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ec28875ae56b82a7591ae9067e57e1cab4d6124
|
4
|
+
data.tar.gz: 713d2a16703c64639066181adeeb2fa3d3acb26f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 136c85eff0b974336cbdc123e8cf1d22fe972c0c6842f75a57be69cfb6968fe47a64a9e9525184515d3a69bf899f01f084cd750c2da2af060eb534e94a6e0dcd
|
7
|
+
data.tar.gz: f0060e523175fb1239c2b8a029b79c98ac9b8e68a4133d1a170294c70353ab001570b248eae4ca509aa5f72a358914a260597318d0162d69a49e5dcde774557b
|
data/Gemfile.lock
CHANGED
@@ -1,34 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mysql_online_migrations (0.1
|
5
|
-
activerecord (
|
6
|
-
activesupport (
|
4
|
+
mysql_online_migrations (1.0.1)
|
5
|
+
activerecord (>= 3.2.15)
|
6
|
+
activesupport (>= 3.2.15)
|
7
7
|
mysql2
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activemodel (
|
13
|
-
activesupport (=
|
14
|
-
builder (~> 3.
|
15
|
-
activerecord (
|
16
|
-
activemodel (=
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
activemodel (4.0.2)
|
13
|
+
activesupport (= 4.0.2)
|
14
|
+
builder (~> 3.1.0)
|
15
|
+
activerecord (4.0.2)
|
16
|
+
activemodel (= 4.0.2)
|
17
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
18
|
+
activesupport (= 4.0.2)
|
19
|
+
arel (~> 4.0.0)
|
20
|
+
activerecord-deprecated_finders (1.0.3)
|
21
|
+
activesupport (4.0.2)
|
21
22
|
i18n (~> 0.6, >= 0.6.4)
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
minitest (~> 4.2)
|
24
|
+
multi_json (~> 1.3)
|
25
|
+
thread_safe (~> 0.1)
|
26
|
+
tzinfo (~> 0.3.37)
|
27
|
+
arel (4.0.2)
|
28
|
+
atomic (1.1.14)
|
29
|
+
builder (3.1.4)
|
25
30
|
coderay (1.0.9)
|
26
31
|
diff-lcs (1.2.5)
|
27
32
|
i18n (0.6.9)
|
28
33
|
logger (1.2.8)
|
29
34
|
method_source (0.8.2)
|
30
|
-
|
31
|
-
|
35
|
+
minitest (4.7.5)
|
36
|
+
multi_json (1.8.4)
|
37
|
+
mysql2 (0.3.15)
|
32
38
|
pry (0.9.12.2)
|
33
39
|
coderay (~> 1.0.5)
|
34
40
|
method_source (~> 0.8)
|
@@ -42,6 +48,8 @@ GEM
|
|
42
48
|
diff-lcs (>= 1.1.3, < 2.0)
|
43
49
|
rspec-mocks (2.14.4)
|
44
50
|
slop (3.4.6)
|
51
|
+
thread_safe (0.1.3)
|
52
|
+
atomic
|
45
53
|
tzinfo (0.3.38)
|
46
54
|
|
47
55
|
PLATFORMS
|
@@ -13,7 +13,23 @@ module MysqlOnlineMigrations
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def connection
|
16
|
-
|
16
|
+
original_connection = super
|
17
|
+
adapter_mode = original_connection.class.name == "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
|
18
|
+
|
19
|
+
@original_adapter ||= if adapter_mode
|
20
|
+
original_connection
|
21
|
+
else
|
22
|
+
original_connection.instance_variable_get(:@delegate)
|
23
|
+
end
|
24
|
+
|
25
|
+
@no_lock_adapter ||= ActiveRecord::ConnectionAdapters::Mysql2AdapterWithoutLock.new(@original_adapter)
|
26
|
+
|
27
|
+
if adapter_mode
|
28
|
+
@no_lock_adapter
|
29
|
+
else
|
30
|
+
original_connection.instance_variable_set(:@delegate, @no_lock_adapter)
|
31
|
+
original_connection
|
32
|
+
end
|
17
33
|
end
|
18
34
|
|
19
35
|
def with_lock
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mysql_online_migrations'
|
3
|
-
s.version = '1.0.
|
3
|
+
s.version = '1.0.2'
|
4
4
|
s.summary = "Use MySQL 5.6+ capacities to enforce online migrations"
|
5
5
|
s.description = "MySQL 5.6 adds a `LOCK=NONE` option to make sure migrations are done with no locking. Let's use it."
|
6
6
|
s.authors = ["Anthony Alberto"]
|
@@ -10,11 +10,34 @@ describe MysqlOnlineMigrations do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
context "#connection" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
shared_examples_for "Mysql2AdapterWithoutLock created" do
|
14
|
+
it "memoizes an instance of Mysql2AdapterWithoutLock" do
|
15
|
+
ActiveRecord::ConnectionAdapters::Mysql2AdapterWithoutLock.should_receive(:new)
|
16
|
+
.with(an_instance_of(ActiveRecord::ConnectionAdapters::Mysql2Adapter)).once.and_call_original
|
17
|
+
3.times { migration.connection }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when migrating' do
|
22
|
+
it "returns an instance of Mysql2AdapterWithoutLock" do
|
23
|
+
migration.connection.should be_an_instance_of(ActiveRecord::ConnectionAdapters::Mysql2AdapterWithoutLock)
|
24
|
+
end
|
25
|
+
|
26
|
+
it_behaves_like "Mysql2AdapterWithoutLock created"
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when rolling back' do
|
30
|
+
before do
|
31
|
+
migration.instance_variable_set(:@connection, ActiveRecord::Migration::CommandRecorder.new(ActiveRecord::Base.connection))
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns an instance of ActiveRecord::Migration::CommandRecorder" do
|
35
|
+
recorder_connection = migration.connection
|
36
|
+
recorder_connection.should be_an_instance_of(ActiveRecord::Migration::CommandRecorder)
|
37
|
+
recorder_connection.instance_variable_get(:@delegate).should be_an_instance_of(ActiveRecord::ConnectionAdapters::Mysql2AdapterWithoutLock)
|
38
|
+
end
|
39
|
+
|
40
|
+
it_behaves_like "Mysql2AdapterWithoutLock created"
|
18
41
|
end
|
19
42
|
end
|
20
43
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_online_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Alberto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|