GlobalSharedDb
A shared database for LINGOCHAMP
Installation
Add this line to your application's Gemfile:
gem 'global_shared_db', '0.0.9'
And then execute:
$ bundle
Or install it yourself as:
$ gem install global_shared_db
Usage
Init DB connection
GlobalSharedDb.setup({
adapter: 'mysql2',
host: 'localhost',
database: 'global_shared_db',
username: 'root',
password: nil
})
switch connection
GlobalSharedDb.establish_connection({host: 'localhost', database: 'xxx'})
Add rake task
如果你的项目需要对数据库做 create/migrate 操作的话, 在 Rakefile
加入如下代码
require 'global_shared_db/load_tasks'
然后就可以运行一个 global_shared_db 的 task
rake global_shared_db:create global_shared_db:migrate
Development
Create test DBs
rake db:create db:migrate
Add model
module GlobalSharedDb
class MyModel < BaseDb
end
end
MyModel # activerecord model