multiverse 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +2 -0
- data/lib/multiverse/patches.rb +9 -9
- data/lib/multiverse/railtie.rb +16 -0
- data/lib/multiverse/version.rb +1 -1
- 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: 564a47885d1668334ca29f1c0d036f8cfe03e850
|
4
|
+
data.tar.gz: 87575b3d26f533b2a53aebdeaa6138c499b75708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a94499ae8268d11fb6a833e564cfb73b165800a7bf7f4cfdcc095f105ed2543f68125a7f22221b548240dbbe65d89e6bdeb89b6cc224da12124f8bd163827ffa
|
7
|
+
data.tar.gz: 1322982a75cd8f8c8e0bb0c0edbdf51361d47a40b7448ca95948021f5adfaf5cae6768a6525eee714bef755d23e04134700314152f17ab8ab6b335167db63d08
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -6,6 +6,8 @@ One of the easiest ways to scale your database is to move large, infrequently-jo
|
|
6
6
|
|
7
7
|
Works with Rails 5+
|
8
8
|
|
9
|
+
[![Build Status](https://travis-ci.org/ankane/multiverse.svg?branch=master)](https://travis-ci.org/ankane/multiverse)
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add this line to your application’s Gemfile:
|
data/lib/multiverse/patches.rb
CHANGED
@@ -16,20 +16,26 @@ module Multiverse
|
|
16
16
|
|
17
17
|
module Migrator
|
18
18
|
def initialize(*_)
|
19
|
-
puts "Migrator#initialize"
|
20
19
|
# ActiveRecord::Migration#initialize calls
|
21
|
-
# ActiveRecord::SchemaMigration.create_table
|
20
|
+
# ActiveRecord::SchemaMigration.create_table and
|
22
21
|
# ActiveRecord::InternalMetadata.create_table
|
23
22
|
# which both inherit from ActiveRecord::Base
|
24
23
|
#
|
25
24
|
# We need to change this for migrations
|
26
|
-
# but not for db:schema:load
|
25
|
+
# but not for db:schema:load, as this
|
26
|
+
# will mess up the Multiverse test environment
|
27
27
|
ActiveRecord::SchemaMigration.singleton_class.prepend(Multiverse::Connection)
|
28
28
|
ActiveRecord::InternalMetadata.singleton_class.prepend(Multiverse::Connection)
|
29
29
|
super
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
module Connection
|
34
|
+
def connection
|
35
|
+
Multiverse.record_class.connection
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
33
39
|
module Migration
|
34
40
|
# TODO don't checkout main connection at all
|
35
41
|
def exec_migration(_, direction)
|
@@ -39,12 +45,6 @@ module Multiverse
|
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
|
-
module Connection
|
43
|
-
def connection
|
44
|
-
Multiverse.record_class.connection
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
48
|
module SchemaDumper
|
49
49
|
def dump(connection = ActiveRecord::Base.connection, stream = STDOUT, config = ActiveRecord::Base)
|
50
50
|
new(Multiverse.record_class.connection, generate_options(Multiverse.record_class)).dump(stream)
|
data/lib/multiverse/railtie.rb
CHANGED
@@ -18,6 +18,22 @@ module Multiverse
|
|
18
18
|
end
|
19
19
|
|
20
20
|
namespace :test do
|
21
|
+
task load_schema: %w(db:test:purge) do
|
22
|
+
begin
|
23
|
+
should_reconnect = ActiveRecord::Base.connection_pool.active_connection?
|
24
|
+
ActiveRecord::Schema.verbose = false
|
25
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema ActiveRecord::Base.configurations[Multiverse.env("test")], :ruby, ENV["SCHEMA"]
|
26
|
+
ensure
|
27
|
+
if should_reconnect
|
28
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Multiverse.env(ActiveRecord::Tasks::DatabaseTasks.env)])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
task load_structure: %w(db:test:purge) do
|
34
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema ActiveRecord::Base.configurations[Multiverse.env("test")], :sql, ENV["SCHEMA"]
|
35
|
+
end
|
36
|
+
|
21
37
|
task purge: %w(environment load_config check_protected_environments) do
|
22
38
|
ActiveRecord::Tasks::DatabaseTasks.purge ActiveRecord::Base.configurations[Multiverse.env("test")]
|
23
39
|
end
|
data/lib/multiverse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multiverse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|