active_record_shards 3.0.0.beta3 → 3.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2b0d1263e6c2ba07f208b1c46f252e254cd341
|
4
|
+
data.tar.gz: b5e951385e67395baaf4e6408441fda6350afc1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f194e8c0726304edff05e03f501b8edf42dff62ea28bdbe90293b93d10cae94499471934387401682dcb7b69f63f5c4eeb428b14ea91da11d3c54a78d964a4e5
|
7
|
+
data.tar.gz: c87fd04a0217d32e9399f58b9f45d6f9e483444e21285c0d1ad29bf4baad3c6c165d988c3b3fd7800db7a950f63efa8a4f0d829a9c13290fec381230573661bc
|
@@ -1,8 +1,12 @@
|
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
|
1
3
|
module ActiveRecordShards
|
2
4
|
module ConfigurationParser
|
3
5
|
module_function
|
4
6
|
|
5
7
|
def explode(conf)
|
8
|
+
conf = conf.deep_dup
|
9
|
+
|
6
10
|
conf.to_a.each do |env_name, env_config|
|
7
11
|
if shards = env_config.delete('shards')
|
8
12
|
env_config['shard_names'] = shards.keys
|
@@ -203,7 +203,7 @@ module ActiveRecordShards
|
|
203
203
|
end
|
204
204
|
|
205
205
|
def columns_with_default_shard
|
206
|
-
if is_sharded? && current_shard_id.nil?
|
206
|
+
if is_sharded? && current_shard_id.nil? && table_name != ActiveRecord::Migrator.schema_migrations_table_name
|
207
207
|
on_first_shard { columns_without_default_shard }
|
208
208
|
else
|
209
209
|
columns_without_default_shard
|
@@ -5,13 +5,17 @@ require 'active_record_shards'
|
|
5
5
|
end
|
6
6
|
|
7
7
|
namespace :db do
|
8
|
-
desc 'Drops the database for the current RAILS_ENV including shards
|
8
|
+
desc 'Drops the database for the current RAILS_ENV including shards'
|
9
9
|
task :drop => :load_config do
|
10
10
|
env_name = defined?(Rails.env) ? Rails.env : RAILS_ENV || 'development'
|
11
11
|
ActiveRecord::Base.configurations.each do |key, conf|
|
12
12
|
if key.starts_with?(env_name) && !key.ends_with?("_slave")
|
13
13
|
begin
|
14
|
-
|
14
|
+
if ActiveRecord::VERSION::MAJOR >= 4
|
15
|
+
ActiveRecord::Tasks::DatabaseTasks.drop(conf)
|
16
|
+
else
|
17
|
+
drop_database(conf)
|
18
|
+
end
|
15
19
|
rescue Exception => e
|
16
20
|
puts "Couldn't drop #{conf['database']} : #{e.inspect}"
|
17
21
|
end
|
@@ -24,14 +28,19 @@ namespace :db do
|
|
24
28
|
Rake::Task["db:setup"].invoke
|
25
29
|
end
|
26
30
|
|
27
|
-
desc "Create the database defined in config/database.yml for the current RAILS_ENV including shards
|
31
|
+
desc "Create the database defined in config/database.yml for the current RAILS_ENV including shards"
|
28
32
|
task :create => :load_config do
|
29
33
|
env_name = defined?(Rails.env) ? Rails.env : RAILS_ENV || 'development'
|
30
34
|
ActiveRecord::Base.configurations.each do |key, conf|
|
31
35
|
if key.starts_with?(env_name) && !key.ends_with?("_slave")
|
32
|
-
|
36
|
+
if ActiveRecord::VERSION::MAJOR >= 4
|
37
|
+
ActiveRecord::Tasks::DatabaseTasks.create(conf)
|
38
|
+
else
|
39
|
+
create_database(conf)
|
40
|
+
end
|
33
41
|
end
|
34
42
|
end
|
43
|
+
ActiveRecord::Base.establish_connection(env_name)
|
35
44
|
end
|
36
45
|
|
37
46
|
desc "Raises an error if there are pending migrations"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_shards
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mick Staugaard
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|