secondbase 0.6.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +16 -0
- data/.yardopts +1 -0
- data/Appraisals +12 -0
- data/CHANGELOG.md +18 -6
- data/Gemfile +3 -12
- data/Guardfile +16 -0
- data/LICENSE.txt +2 -1
- data/README.md +144 -0
- data/Rakefile +18 -41
- data/VERSION +1 -1
- data/gemfiles/rails40.gemfile +8 -0
- data/gemfiles/rails41.gemfile +8 -0
- data/gemfiles/rails42.gemfile +8 -0
- data/lib/rails/second_base/generators/migration_generator.rb +25 -0
- data/lib/second_base.rb +20 -0
- data/lib/second_base/base.rb +8 -0
- data/lib/second_base/databases.rake +127 -0
- data/lib/second_base/forced.rb +21 -0
- data/lib/second_base/on_base.rb +36 -0
- data/lib/second_base/railtie.rb +40 -0
- data/lib/second_base/test_help.rb +11 -0
- data/lib/second_base/version.rb +3 -0
- data/lib/secondbase.rb +1 -46
- data/secondbase.gemspec +25 -75
- data/test/cases/dbtask_test.rb +225 -0
- data/test/cases/forced_test.rb +49 -0
- data/test/cases/generator_test.rb +41 -0
- data/test/cases/on_base_test.rb +35 -0
- data/test/cases/railtie_test.rb +31 -0
- data/test/dummy_app/Rakefile +2 -0
- data/test/dummy_app/app/controllers/application_controller.rb +7 -0
- data/test/dummy_app/app/helpers/application_helper.rb +3 -0
- data/test/dummy_app/app/models/comment.rb +6 -0
- data/test/dummy_app/app/models/comment_forced.rb +6 -0
- data/test/dummy_app/app/models/post.rb +7 -0
- data/test/dummy_app/app/models/user.rb +6 -0
- data/test/dummy_app/bin/rails +5 -0
- data/test/dummy_app/config/database.yml +14 -0
- data/test/dummy_app/config/routes.rb +3 -0
- data/test/dummy_app/db/migrate/20141209165002_create_users.rb +11 -0
- data/test/dummy_app/db/migrate/20141214142700_create_posts.rb +12 -0
- data/test/dummy_app/db/secondbase/migrate/20151202075826_create_comments.rb +11 -0
- data/test/dummy_app/init.rb +40 -0
- data/test/dummy_app/log/.keep +0 -0
- data/test/dummy_app/tmp/.keep +0 -0
- data/test/test_helper.rb +36 -0
- data/test/test_helpers/dummy_app_helpers.rb +90 -0
- data/test/test_helpers/rails_version_helpers.rb +29 -0
- data/test/test_helpers/stream_helpers.rb +40 -0
- metadata +220 -139
- data/.document +0 -5
- data/Gemfile.lock +0 -38
- data/README.rdoc +0 -143
- data/lib/generators/secondbase/USAGE +0 -19
- data/lib/generators/secondbase/migration_generator.rb +0 -36
- data/lib/generators/secondbase/templates/migration.rb +0 -13
- data/lib/secondbase/active_record/associations/has_and_belongs_to_many_association.rb +0 -66
- data/lib/secondbase/active_record/base.rb +0 -13
- data/lib/secondbase/active_record/fixtures.rb +0 -66
- data/lib/secondbase/active_record/patches.rb +0 -13
- data/lib/secondbase/active_record/test_fixtures.rb +0 -32
- data/lib/secondbase/model.rb +0 -11
- data/lib/secondbase/railtie.rb +0 -10
- data/lib/secondbase/rake_method_chain.rb +0 -22
- data/lib/secondbase/tasks.rb +0 -219
- data/rails_generators/secondbase/USAGE +0 -29
- data/rails_generators/secondbase/secondbase_migration_generator.rb +0 -20
- data/rails_generators/secondbase/templates/migration.rb +0 -15
- data/test/helper.rb +0 -18
- data/test/test_secondbase.rb +0 -7
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c8690f339e1891e3267b5ffee18a8f13033d42a8
|
4
|
+
data.tar.gz: 6055c37a690ddb03905c4eb59ebeac874f1cf0d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c3bc5947e3dd04c8ac368a274ca88a35c8a27940fb19f33ae7567c3c521cd040d8f6c4e94064879e867564d0cf3e350f36f00d1bbce6207108d631e745c0549
|
7
|
+
data.tar.gz: b9623cbadc8d55f518cd3e57d783b748c92b3bfac11b97c9fc7cf323df9faf824218aced9aac922d751db218557781a31a4adb70156ef7b9baa06540f5c41a56
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
sudo: false
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- 2.0
|
5
|
+
- 2.1
|
6
|
+
- 2.2.3
|
7
|
+
gemfile:
|
8
|
+
- gemfiles/rails40.gemfile
|
9
|
+
- gemfiles/rails41.gemfile
|
10
|
+
- gemfiles/rails42.gemfile
|
11
|
+
install:
|
12
|
+
- gem install bundler
|
13
|
+
- bundle --version
|
14
|
+
- bundle install
|
15
|
+
script:
|
16
|
+
- bundle exec rake test
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--exclude test/**/*.rb
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
-
# CHANGELOG
|
2
1
|
|
3
|
-
|
2
|
+
# Change Log
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
Please follow the format set down in http://keepachangelog.com
|
5
|
+
|
6
|
+
|
7
|
+
## v1.0
|
8
|
+
|
9
|
+
Initial re-write supporting Rails 4.x. Please see README.md for full details.
|
10
|
+
|
11
|
+
|
12
|
+
## v0.6
|
13
|
+
|
14
|
+
Support for Rails 3.x. For 2.x support, check out the branch `rails_2_3` or version v0.5 of the gem.
|
15
|
+
|
16
|
+
#### Fixed
|
17
|
+
|
18
|
+
* The `has_and_belongs_to_many` associations, for SecondBase models.
|
19
|
+
* Patched `ActiveRecord::TestFixtures` so that transactional fixture support is respected for the SecondBase.
|
20
|
+
* Reorganized monkey patches to make it easier to work in fixes for different versions of Rails.
|
data/Gemfile
CHANGED
@@ -1,13 +1,4 @@
|
|
1
|
-
source "
|
2
|
-
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
1
|
+
source "https://rubygems.org"
|
2
|
+
gemspec
|
5
3
|
|
6
|
-
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
group :development do
|
9
|
-
gem "shoulda", ">= 0"
|
10
|
-
gem "bundler", ">= 1.0.0"
|
11
|
-
gem "jeweler", "~> 1.8.2"
|
12
|
-
gem "activerecord", "~> 3.0.0"
|
13
|
-
end
|
4
|
+
gem 'terminal-notifier-guard' if RUBY_PLATFORM =~ /darwin/
|
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
clearing :on
|
2
|
+
notification :terminal_notifier if defined?(TerminalNotifier)
|
3
|
+
ignore!([
|
4
|
+
/test\/dummy_app/,
|
5
|
+
/byebug/
|
6
|
+
])
|
7
|
+
|
8
|
+
guard :minitest, {
|
9
|
+
all_on_start: true,
|
10
|
+
autorun: false,
|
11
|
+
include: ['lib', 'test'],
|
12
|
+
test_folders: ['test'],
|
13
|
+
test_file_patterns: ["*_test.rb"]
|
14
|
+
} do
|
15
|
+
watch(%r{.*}) { 'test' }
|
16
|
+
end
|
data/LICENSE.txt
CHANGED
data/README.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
|
2
|
+
![SecondBase Logo](https://cloud.githubusercontent.com/assets/2381/12219457/5a5aab4e-b712-11e5-92e1-de6487aa0809.png)
|
3
|
+
<hr>
|
4
|
+
Seamless second database integration for Rails. SecondBase provides support for Rails to manage dual databases by focusing on ActiveRecord tasks that create, migrate, and test your databases.
|
5
|
+
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/secondbase.png)](http://badge.fury.io/rb/secondbase)
|
7
|
+
[![Build Status](https://secure.travis-ci.org/customink/secondbase.png)](http://travis-ci.org/customink/secondbase)
|
8
|
+
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
To get started with your new second database, update your database.yml to include a `secondbase` config key. All SecondBase configurations per Rails environment go under this config key.
|
13
|
+
|
14
|
+
```yaml
|
15
|
+
# Default configurations:
|
16
|
+
development:
|
17
|
+
adapter: sqlserver
|
18
|
+
database: myapp_development
|
19
|
+
test:
|
20
|
+
adapter: sqlserver
|
21
|
+
database: myapp_test
|
22
|
+
# SecondBase configurations:
|
23
|
+
secondbase:
|
24
|
+
development:
|
25
|
+
adapter: mysql
|
26
|
+
database: myapp_development
|
27
|
+
test:
|
28
|
+
adapter: mysql
|
29
|
+
database: myapp_test
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Database Tasks
|
33
|
+
|
34
|
+
SecondBase aims to work seamlessly within your Rails application. When it makes sense, we run a mirrored `db:second_base` task for matching ActiveRecord base database task. For example:
|
35
|
+
|
36
|
+
```shell
|
37
|
+
$ rake db:create
|
38
|
+
```
|
39
|
+
|
40
|
+
This will not only create your base development database, but it will also create your second database as specified by the configuration within the `:secondbase` section of your database.yml. Below is a complete list of `:db` tasks that automatically run a mirrored `:db:second_base` task. Some private or over lapping tasks, like schema dump/loading or `db:setup`, are not listed.
|
41
|
+
|
42
|
+
* db:create
|
43
|
+
* db:create:all
|
44
|
+
* db:drop
|
45
|
+
* db:drop:all
|
46
|
+
* db:purge
|
47
|
+
* db:purge:all
|
48
|
+
* db:migrate
|
49
|
+
* db:test:purge
|
50
|
+
* db:test:prepare
|
51
|
+
|
52
|
+
Not all base database tasks make sense to run a mirrored SecondBase task. These include tasks that move a single migration up/down, reporting on your database's current status/version, and others. These tasks have to be run explicitly and only operate on your SecondBase database. Each support any feature that their matching `:db` task has. For example, using `VERSION=123` to target a specific migration.
|
53
|
+
|
54
|
+
* db:second_base:migrate:up
|
55
|
+
* db:second_base:migrate:down
|
56
|
+
* db:second_base:migrate:reset
|
57
|
+
* db:second_base:migrate:redo
|
58
|
+
* db:second_base:migrate:status
|
59
|
+
* db:second_base:rollback
|
60
|
+
* db:second_base:forward
|
61
|
+
* db:second_base:version
|
62
|
+
|
63
|
+
#### Migration Generator
|
64
|
+
|
65
|
+
SecondBase migrations are stored in your application's `db/secondbase/migrate` directory. Likewise, SecondBase will also dump your schema/structure file into the `db/secondbase` directory. Full support for ActiveRecord's schema format being set to either `:ruby` or `:sql` is supported.
|
66
|
+
|
67
|
+
Migrations can be generated using the `second_base:migration` name. Our generator is a subclass of ActiveRecord's. This means the SecondBase migration generator supports whatever features and arguments are supported by your current Rails version. For example:
|
68
|
+
|
69
|
+
```shell
|
70
|
+
$ rails generate second_base:migration CreateWidgetsTable
|
71
|
+
$ rails generate second_base:migration AddTitleBodyToPost title:string body:text
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Models
|
75
|
+
|
76
|
+
Any model who's table resides in your second database needs to inherit from `SecondBase::Base`. ActiveRecord associations will still work between your base ActiveRecord and SecondBase models!
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
class Widget < SecondBase::Base
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
class User < ActiveRecord::Base
|
84
|
+
has_many :widgets
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
#### Forced Connections
|
89
|
+
|
90
|
+
Sometimes you want to force a model that inherits from `ActiveRecord::Base` to use the `SecondBase::Base` connection. Using the `SecondBase::Forced` module is a great way to accomplish this. By using this module, we do all the work to ensure the connection, management, and pool are properly freedom patched.
|
91
|
+
|
92
|
+
We recomend forcing modules using a Rails initializer. This example below forces both the [DelayedJob ActiveRecord Backend](https://github.com/collectiveidea/delayed_job_active_record) and ActiveRecord session store to use your SecondBase database.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
# In config/initializers/second_base.rb
|
96
|
+
Delayed::Backend::ActiveRecord::Job.extend SecondBase::Forced
|
97
|
+
ActiveRecord::SessionStore::Session.extend SecondBase::Forced
|
98
|
+
```
|
99
|
+
|
100
|
+
#### Testing & DB Synchronization
|
101
|
+
|
102
|
+
Rails 4.2 brought about a new way to keep your test database in sync by checking schema migrations. Where previously forcing a full test database schema load, Rails 4.2 and up is able to run your tests much faster. In order for SecondBase to take advantage of this, you will need to include our test help file directly following the Rails one. Open your `test_helper.rb` and add our `second_base/test_help` after `rails/test_help`.
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
ENV["RAILS_ENV"] = "test"
|
106
|
+
require File.expand_path('../../config/environment', __FILE__)
|
107
|
+
require 'rails/test_help'
|
108
|
+
require 'second_base/test_help'
|
109
|
+
```
|
110
|
+
|
111
|
+
#### Configurations
|
112
|
+
|
113
|
+
All SecondBase railtie settings are best done in a `config/initializers/secondbase.rb` file. We support the following configurations:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
config.second_base.path # Default: 'db/secondbase'
|
117
|
+
config.second_base.config_key # Default: 'secondbase'
|
118
|
+
```
|
119
|
+
|
120
|
+
* `path` - Used as location for migrations & schema. Path is relative to application root.
|
121
|
+
* `config_key` - The key to in database.yml/configurations to search for SecondBase configs.
|
122
|
+
|
123
|
+
|
124
|
+
## Versions
|
125
|
+
|
126
|
+
The current master branch is for Rails v4.0.0 and up and. We have older work in previous v1.0 releases which partial work for Rails 3.2 or lower. These old versions are feature incomplete and are not supported.
|
127
|
+
|
128
|
+
|
129
|
+
## Contributing
|
130
|
+
|
131
|
+
We use the [Appraisal](https://github.com/thoughtbot/appraisal) gem from Thoughtbot to help us test different versions of Rails. The `rake appraisal test` command actually runs our test suite against all Rails versions in our `Appraisal` file. So after cloning the repo, running the following commands.
|
132
|
+
|
133
|
+
```shell
|
134
|
+
$ bundle install
|
135
|
+
$ bundle exec appraisal update
|
136
|
+
$ bundle exec appraisal rake test
|
137
|
+
```
|
138
|
+
|
139
|
+
If you want to run the tests for a specific Rails version, use one of the appraisal names found in our `Appraisals` file. For example, the following will run our tests suite for Rails 4.1.x.
|
140
|
+
|
141
|
+
```shell
|
142
|
+
$ bundle exec appraisal rails41 rake test
|
143
|
+
```
|
144
|
+
|
data/Rakefile
CHANGED
@@ -1,47 +1,24 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'rake'
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
11
3
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
gem.homepage = "http://github.com/karledurante/secondbase"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.summary = %Q{Allow Rails manage second database in your projects}
|
19
|
-
gem.description = %Q{Secondbase provides support to Rails to create a homogeneous environment for a dual database project. Using the rake tasks already familiar to you, this gem enables Rails to work with two primary databases, instead of just one.}
|
20
|
-
gem.email = "kdurante@customink.com"
|
21
|
-
gem.authors = ["karledurante"]
|
22
|
-
gem.add_development_dependency 'activerecord', '~> 3.0.0'
|
23
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
24
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
25
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
26
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs = ['lib','test']
|
6
|
+
t.test_files = FileList['test/**/*_test.rb']
|
7
|
+
t.verbose = true
|
27
8
|
end
|
28
|
-
Jeweler::RubygemsDotOrgTasks.new
|
29
9
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
test
|
10
|
+
desc "Bootstrap development/test DB setup."
|
11
|
+
task :bootstrap do
|
12
|
+
# ENV['DATBASE_URL'] = 'mysql://root@localhost/secondbase_url'
|
13
|
+
require_relative './test/dummy_app/init'
|
14
|
+
require_relative './test/test_helpers/dummy_app_helpers'
|
15
|
+
include SecondBase::DummyAppHelpers
|
16
|
+
# dummy_root = File.expand_path "#{__dir__}/test/dummy_app"
|
17
|
+
Dir.chdir(dummy_root) { `rake db:create` }
|
18
|
+
delete_dummy_files
|
35
19
|
end
|
36
20
|
|
37
|
-
task :default
|
38
|
-
|
39
|
-
|
40
|
-
Rake::RDocTask.new do |rdoc|
|
41
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
-
|
43
|
-
rdoc.rdoc_dir = 'rdoc'
|
44
|
-
rdoc.title = "secondbase #{version}"
|
45
|
-
rdoc.rdoc_files.include('README*')
|
46
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
task :default do
|
22
|
+
Kernel.system 'appraisal update'
|
23
|
+
Kernel.system 'appraisal rake test'
|
47
24
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/migration/migration_generator'
|
3
|
+
require 'rails/generators/active_record'
|
4
|
+
require 'rails/generators/active_record/migration/migration_generator'
|
5
|
+
|
6
|
+
module SecondBase
|
7
|
+
class MigrationGenerator < ActiveRecord::Generators::MigrationGenerator
|
8
|
+
|
9
|
+
source_root ActiveRecord::Generators::MigrationGenerator.source_root
|
10
|
+
|
11
|
+
def self.desc
|
12
|
+
Rails::Generators::MigrationGenerator.desc
|
13
|
+
end
|
14
|
+
|
15
|
+
include(Module.new{
|
16
|
+
|
17
|
+
def migration_template(*args)
|
18
|
+
args[1].sub! 'db/migrate', "#{Railtie.config_path}/migrate" if args[1]
|
19
|
+
super(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
})
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/second_base.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'active_record'
|
3
|
+
require 'active_record/railtie'
|
4
|
+
require 'second_base/version'
|
5
|
+
require 'second_base/railtie'
|
6
|
+
require 'second_base/on_base'
|
7
|
+
require 'second_base/forced'
|
8
|
+
|
9
|
+
module SecondBase
|
10
|
+
|
11
|
+
extend ActiveSupport::Autoload
|
12
|
+
|
13
|
+
autoload :Base
|
14
|
+
|
15
|
+
def self.config(env = nil)
|
16
|
+
config = ActiveRecord::Base.configurations[Railtie.config_key]
|
17
|
+
config ? config[env || Rails.env] : nil
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
namespace :db do
|
2
|
+
namespace :second_base do
|
3
|
+
|
4
|
+
namespace :create do
|
5
|
+
task :all do
|
6
|
+
SecondBase.on_base { Rake::Task['db:create:all'].execute }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
task :create do
|
11
|
+
SecondBase.on_base { Rake::Task['db:create'].execute }
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :drop do
|
15
|
+
task :all do
|
16
|
+
SecondBase.on_base { Rake::Task['db:drop:all'].execute }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
task :drop do
|
21
|
+
SecondBase.on_base { Rake::Task['db:drop'].execute }
|
22
|
+
end
|
23
|
+
|
24
|
+
namespace :purge do
|
25
|
+
task :all do
|
26
|
+
SecondBase.on_base { Rake::Task['db:purge:all'].execute }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
task :purge do
|
31
|
+
SecondBase.on_base { Rake::Task['db:purge'].execute }
|
32
|
+
end
|
33
|
+
|
34
|
+
task :migrate do
|
35
|
+
SecondBase.on_base { Rake::Task['db:migrate'].execute }
|
36
|
+
end
|
37
|
+
|
38
|
+
namespace :migrate do
|
39
|
+
|
40
|
+
task :redo => ['db:load_config'] do
|
41
|
+
SecondBase.on_base { Rake::Task['db:migrate:redo'].execute }
|
42
|
+
end
|
43
|
+
|
44
|
+
task :reset => ['db:second_base:drop', 'db:second_base:create', 'db:second_base:migrate']
|
45
|
+
|
46
|
+
task :up => ['db:load_config'] do
|
47
|
+
SecondBase.on_base { Rake::Task['db:migrate:up'].execute }
|
48
|
+
end
|
49
|
+
|
50
|
+
task :down => ['db:load_config'] do
|
51
|
+
SecondBase.on_base { Rake::Task['db:migrate:down'].execute }
|
52
|
+
end
|
53
|
+
|
54
|
+
task :status => ['db:load_config'] do
|
55
|
+
SecondBase.on_base { Rake::Task['db:migrate:status'].execute }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
task :rollback => ['db:load_config'] do
|
61
|
+
SecondBase.on_base { Rake::Task['db:rollback'].execute }
|
62
|
+
end
|
63
|
+
|
64
|
+
task :forward => ['db:load_config'] do
|
65
|
+
SecondBase.on_base { Rake::Task['db:forward'].execute }
|
66
|
+
end
|
67
|
+
|
68
|
+
task :abort_if_pending_migrations do
|
69
|
+
SecondBase.on_base { Rake::Task['db:abort_if_pending_migrations'].execute }
|
70
|
+
end
|
71
|
+
|
72
|
+
task :version => ['db:load_config'] do
|
73
|
+
SecondBase.on_base { Rake::Task['db:version'].execute }
|
74
|
+
end
|
75
|
+
|
76
|
+
namespace :schema do
|
77
|
+
|
78
|
+
task :load do
|
79
|
+
SecondBase.on_base { Rake::Task['db:schema:load'].execute }
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
namespace :structure do
|
85
|
+
|
86
|
+
task :load do
|
87
|
+
SecondBase.on_base { Rake::Task['db:structure:load'].execute }
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
namespace :test do
|
93
|
+
|
94
|
+
task :purge do
|
95
|
+
SecondBase.on_base { Rake::Task['db:test:purge'].execute }
|
96
|
+
end
|
97
|
+
|
98
|
+
task :load_schema do
|
99
|
+
SecondBase.on_base { Rake::Task['db:test:load_schema'].execute }
|
100
|
+
end
|
101
|
+
|
102
|
+
task :load_structure do
|
103
|
+
SecondBase.on_base { Rake::Task['db:test:load_structure'].execute }
|
104
|
+
end
|
105
|
+
|
106
|
+
task :prepare do
|
107
|
+
SecondBase.on_base { Rake::Task['db:test:prepare'].execute }
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
%w{
|
116
|
+
create:all create drop drop:all purge:all purge
|
117
|
+
migrate abort_if_pending_migrations
|
118
|
+
schema:load structure:load
|
119
|
+
test:purge test:load_schema test:load_structure test:prepare
|
120
|
+
}.each do |name|
|
121
|
+
task = Rake::Task["db:#{name}"] rescue nil
|
122
|
+
next unless task
|
123
|
+
task.enhance do
|
124
|
+
Rake::Task["db:load_config"].invoke
|
125
|
+
Rake::Task["db:second_base:#{name}"].invoke
|
126
|
+
end
|
127
|
+
end
|