ruby-on-rails - 如何使用 rake db :dump:schema 转储多个 postgres 模式

标签 ruby-on-rails ruby-on-rails-3 postgresql

我们的 postgres 数据库有两个模式:公共(public)模式和元数据模式。我的测试数据库中需要这两个模式,但是 rake db:schema:dump 只转储公共(public)模式。如果我将 schema_search_path: "public, metadata" 添加到我的 database.yml 文件中,它会转储两个模式,但模式信息不存在。

如何将这两个模式转储到 db/schema.rb 以便我可以使用 rake db:test:prepare 加载它们?

最佳答案

在我看来答案是使用结构文件而不是模式文件。

将此添加到 application.rb

# use a .sql structure instead of a schema.rb for the schema
config.active_record.schema_format = :sql

删除您的 schema.rb 文件

现在这将使用结构 (sql) 而不是模式 (rb) 转储您的数据库,并且它可以更具表现力。但是,它现在与您的数据库供应商相关联(对我们来说不是什么大问题)。

bundle exec rake db:test:prepare

关于ruby-on-rails - 如何使用 rake db :dump:schema 转储多个 postgres 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19054541/

相关文章:

javascript - 通过从 javascript 文件调用部分更新 html 元素

ruby-on-rails - 更新到最新的 OS X 后出现 Postgres 错误

java - postgresql 错误 : missing FROM-clause entry for table in JAVA query execution

ruby-on-rails - Rails 中用于生成报告的 RESTful 路由

ruby-on-rails - 设计可邀请的批量邀请 - Ruby on rails

ruby-on-rails - ruby rails : "cannot load such file" eventmachine

ruby-on-rails - Rails button_to正在调用POST操作,试图调用OUT操作

ruby-on-rails - 乘客错误 : The application spawner server exited unexpectedly: Unexpected end-of-file detected

ruby-on-rails - rails 3,Heroku : Taps Server Error: PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xba

node.js - 网络实时分析仪表板 : which technologies should use?( Node/django、cassandra/mongodb ...)