Module: CouchRest::Model::Utils::Migrate
Overview
Handle CouchDB Design Document migrations.
Actual migrations are handled by the Design document, this serves as a utility to find all the CouchRest Model submodels and perform the migration on them.
Also contains some more advanced support for handling proxied models.
Examples of usage:
# Ensure all models have been loaded (only Rails)
CouchRest::Model::Utils::Migrate.load_all_models
# Migrate all regular models (not proxied)
CouchRest::Model::Utils::Migrate.all_models
# Migrate all models and submodels of proxies
CouchRest::Model::Utils::Migrate.all_models_and_proxies
Typically however you’d want to run these methods from the rake tasks:
$ rake couchrest:migrate_with_proxies
NOTE: This is an experimental feature that is not yet properly tested.
Instance Method Summary collapse
-
#all_models ⇒ Object
Go through each class that inherits from CouchRest::Model::Base and attempt to migrate the design documents.
- #all_models_and_proxies ⇒ Object
-
#load_all_models ⇒ Object
Make an attempt at loading all the files in this Rails application’s models directory.
Instance Method Details
#all_models ⇒ Object
Go through each class that inherits from CouchRest::Model::Base and attempt to migrate the design documents.
44 45 46 47 |
# File 'lib/couchrest/model/utils/migrate.rb', line 44 def all_models callbacks = migrate_each_model(find_models) cleanup(callbacks) end |
#all_models_and_proxies ⇒ Object
49 50 51 52 53 |
# File 'lib/couchrest/model/utils/migrate.rb', line 49 def all_models_and_proxies callbacks = migrate_each_model(find_models) callbacks += () cleanup(callbacks) end |
#load_all_models ⇒ Object
Make an attempt at loading all the files in this Rails application’s models directory.
34 35 36 37 38 39 40 |
# File 'lib/couchrest/model/utils/migrate.rb', line 34 def load_all_models # Make a reasonable effort to load all models return unless defined?(Rails) Dir[Rails.root + 'app/models/**/*.rb'].each do |path| require path end end |