2011-07-29 34 views
2

在使用postgres模式(即schema_name.users)的應用程序上運行rake db:schema:dump時,它看起來只是爲db用戶的搜索路徑中的第一個模式轉儲表。有沒有一種方法可以包含來自多個模式的表格?在rake數據庫中包含多個postgres模式:schema:dump?

以不同的方式陳述問題:

createdb myapp 

psql myapp -U postgres -c "create table stuff" 
#=> creates table "stuff" in the public schema 

psql myapp -U postgres -c "create schema specific_thing" 

psql myapp -U postgres -c 'create table "specific_thing".users(id int)' 

createuser -U postgres -S -D -R special_user 

psql myapp -U postgres -c "grant all on schema specific_thing to special_user" 

psql myapp -U postgres -c "ALTER USER special_user SET search_path TO specific_thing,public" 

database.yml:

... 

development: 
    adapter: postgresql 
    database: stuff 
    username: special_user 
    password: 
    host: localhost 

... 

運行:rake db:schema:dump

僅從specific_thing模式轉儲users talbe,而忽略公共架構的一切。

回答

1

所以這就是我發現的。我沒有代碼在我面前,所以我不能指出任何具體的東西,但PostgresAdapter中有一些代碼標識適配器認爲是可用的「表」。適配器假定它總是要處理'公共'模式(公共實際上在獲取表列表的查詢中進行了硬編碼),所以我對該問題的解決方案涉及到使PostgresAdapter繼承以對它的'表'有不同的概念,是。這讓我大部分時間都在那裏。還有其他一些障礙需要克服,但將這件作品裝入拼圖後,一切都變得更加清晰。但絕對需要花費一些時間在Rails源代碼中。

+0

你能轉儲多個模式嗎? –

相關問題