database.ymlのPostgreSQLアダプタschema_search_pathは問題を解決しますか?
development:
adapter: postgresql
encoding: utf-8
database: solidus
host: 127.0.0.1
port: 5432
username: postgres
password: postgres
schema_search_path: "discogs,public"
それとも、あなたのことができスキーマごとに異なる接続を指定するには:各接続が定義された後、
public_schema:
adapter: postgresql
encoding: utf-8
database: solidus
host: 127.0.0.1
port: 5432
username: postgres
password: postgres
schema_search_path: "public"
discogs_schema:
adapter: postgresql
encoding: utf-8
database: solidus
host: 127.0.0.1
port: 5432
username: postgres
password: postgres
schema_search_path: "discogs"
二つのモデル作成:
class PublicSchema < ActiveRecord::Base
self.abstract_class = true
establish_connection :public_schema
end
class DiscoGsSchema < ActiveRecord::Base
self.abstract_class = true
establish_connection :discogs_schema
end
をそして、すべてのモデルが継承それぞれのスキーマ:
class MyModelFromPublic < PublicSchema
set_table_name :my_table_name
end
class MyOtherModelFromDiscoGs < DiscoGsSchema
set_table_name :disco
end
私はそれが助けてくれることを願っています。
db:create rakeタスクを使用してデータベースを設定するときに、どのように非公開スキーマを作成しますか? template1データベースにスキーマを追加することは可能です。しかし、通常のレール/レーキ開発プロセスの一環としてそれを行う方法はありますか? – TsenYing
@TsenYing [pg_power gemがあります](http://stackoverflow.com/a/18227887/673826)は1つのオプションです。その[home is here](https://github.com/TMXCredit/pg_power)です。それは2年のために更新されていません。もう一つのオプションは* db *名前空間に* create * rakeタスクを書いてそこにあなたのものを追加することかもしれません。 – mlt