couchrest_model 2.1.0.beta1 → 2.1.0.beta2
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/VERSION +1 -1
- data/history.md +4 -0
- data/lib/couchrest/model/utils/migrate.rb +24 -8
- data/lib/tasks/migrations.rake +24 -10
- 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: d9d09e0aa83e793199ecb3d666f57623870fd63c
|
4
|
+
data.tar.gz: e4faadfdc65e72a4212a59932c8953fb80ae04ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61d9e906196acbd827666ca4541b682b066b48bafe1adcdf34bd08f163a4c977ec5c22769afde441c5b259694239298d584308f59c67eaa95db2f62e4b1965a7
|
7
|
+
data.tar.gz: 13360a9c60b859e5e39723d585efe273f57198d70e8c38662dc248c5449b04fb07b3d36c91689e78e42c13ba851e30872f37c5b060fcfabdd45a4a4aec06cad2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.0.
|
1
|
+
2.1.0.beta2
|
data/history.md
CHANGED
@@ -22,7 +22,22 @@ module CouchRest
|
|
22
22
|
#
|
23
23
|
# Typically however you'd want to run these methods from the rake tasks:
|
24
24
|
#
|
25
|
-
# $ rake couchrest:migrate_with_proxies
|
25
|
+
# $ rake couchrest:designs:migrate_with_proxies
|
26
|
+
#
|
27
|
+
# In production environments, you sometimes want to prepare large view
|
28
|
+
# indexes that take a long term to generate before activating them. To
|
29
|
+
# support this scenario we provide the `:activate` option:
|
30
|
+
#
|
31
|
+
# # Prepare all models, but do not activate
|
32
|
+
# CouchRest::Model::Utils::Migrate.all_models(activate: false)
|
33
|
+
#
|
34
|
+
# Or from Rake:
|
35
|
+
#
|
36
|
+
# $ rake couchrest:designs:prepare
|
37
|
+
#
|
38
|
+
# Once finished, just before uploading your code you can repeat without
|
39
|
+
# the `activate` option so that the view indexes are ready for the new
|
40
|
+
# designs.
|
26
41
|
#
|
27
42
|
# NOTE: This is an experimental feature that is not yet properly tested.
|
28
43
|
#
|
@@ -41,15 +56,16 @@ module CouchRest
|
|
41
56
|
|
42
57
|
# Go through each class that inherits from CouchRest::Model::Base and
|
43
58
|
# attempt to migrate the design documents.
|
44
|
-
def all_models
|
59
|
+
def all_models(opts = {})
|
60
|
+
opts.reverse_merge!(activate: true, with_proxies: false)
|
45
61
|
callbacks = migrate_each_model(find_models)
|
46
|
-
|
62
|
+
callbacks += migrate_each_proxying_model(find_proxying_models) if opts[:with_proxies]
|
63
|
+
activate_designs(callbacks) if opts[:activate]
|
47
64
|
end
|
48
65
|
|
49
|
-
def all_models_and_proxies
|
50
|
-
|
51
|
-
|
52
|
-
cleanup(callbacks)
|
66
|
+
def all_models_and_proxies(opts = {})
|
67
|
+
opts[:with_proxies] = true
|
68
|
+
all_models(opts)
|
53
69
|
end
|
54
70
|
|
55
71
|
protected
|
@@ -98,7 +114,7 @@ module CouchRest
|
|
98
114
|
callback ? {:design => design, :proc => callback, :db => db || model.database} : nil
|
99
115
|
end
|
100
116
|
|
101
|
-
def
|
117
|
+
def activate_designs(methods)
|
102
118
|
methods.compact.each do |cb|
|
103
119
|
name = "/#{cb[:db].name}/#{cb[:design]['_id']}"
|
104
120
|
puts "Activating new design: #{name}"
|
data/lib/tasks/migrations.rake
CHANGED
@@ -5,17 +5,31 @@
|
|
5
5
|
#
|
6
6
|
namespace :couchrest do
|
7
7
|
|
8
|
-
|
9
|
-
task :migrate => :environment do
|
10
|
-
CouchRest::Model::Utils::Migrate.load_all_models
|
11
|
-
CouchRest::Model::Utils::Migrate.all_models
|
12
|
-
end
|
8
|
+
namespace :designs do
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
desc "Migrate all the design docs found in each model"
|
11
|
+
task :migrate => :environment do
|
12
|
+
CouchRest::Model::Utils::Migrate.load_all_models
|
13
|
+
CouchRest::Model::Utils::Migrate.all_models
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Migrate all the design docs found in each model, but do not active the designs"
|
17
|
+
task :prepare => :environment do
|
18
|
+
CouchRest::Model::Utils::Migrate.load_all_models
|
19
|
+
CouchRest::Model::Utils::Migrate.all_models(activate: false)
|
20
|
+
end
|
19
21
|
|
22
|
+
desc "Migrate all the design docs "
|
23
|
+
task :migrate_with_proxies => :environment do
|
24
|
+
CouchRest::Model::Utils::Migrate.load_all_models
|
25
|
+
CouchRest::Model::Utils::Migrate.all_models_and_proxies
|
26
|
+
end
|
20
27
|
|
28
|
+
desc "Migrate all the design docs "
|
29
|
+
task :prepare_with_proxies => :environment do
|
30
|
+
CouchRest::Model::Utils::Migrate.load_all_models
|
31
|
+
CouchRest::Model::Utils::Migrate.all_models_and_proxies(activate: false)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
21
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchrest_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.
|
4
|
+
version: 2.1.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J. Chris Anderson
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: couchrest
|