Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在rake db:schema:dump中包含多个postgres模式?_Ruby On Rails_Database_Postgresql_Schema_Rake - Fatal编程技术网

Ruby on rails 在rake db:schema:dump中包含多个postgres模式?

Ruby on rails 在rake db:schema:dump中包含多个postgres模式?,ruby-on-rails,database,postgresql,schema,rake,Ruby On Rails,Database,Postgresql,Schema,Rake,在使用postgres模式(即schema_name.users)的应用程序上运行rake db:schema:dump时,看起来它只是在为db用户搜索路径中的第一个模式转储表。是否有一种方法可以包含来自多个模式的表 要以不同的方式说明问题: createdb myapp psql myapp -U postgres -c "create table stuff" #=> creates table "stuff" in the public schema psql myapp -U

在使用postgres模式(即schema_name.users)的应用程序上运行rake db:schema:dump时,看起来它只是在为db用户搜索路径中的第一个模式转储表。是否有一种方法可以包含来自多个模式的表

要以不同的方式说明问题:

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

...
正在运行:
rakedb:schema:dump


只转储
用户
可能来自
特定事物
模式,忽略公共模式中的所有内容。

以下是我的发现。我面前没有代码,因此无法具体指出任何内容,但PostgresAdapter中有一些代码可以标识适配器认为是其可用“表”的内容。适配器假定它总是要处理“public”模式(public实际上是在获取表列表的查询中硬编码的),因此我的解决方案涉及到将PostgresAdapter子类化,以便对它的“表”有不同的概念。这让我一路走到那里。还有一些其他的障碍需要克服,但在把这一块拼进拼图之后,一切都变得更加清晰了。但肯定涉及到在Rails源代码中花费一些时间。

您能够转储多个模式吗?