Rails - 迁移错误 - PG::InvalidSchemaName: 错误:无效的模式名称

4

当我运行rake db:migrate时,会出现以下错误:

ActiveRecord::StatementInvalid: PG::InvalidSchemaName: ERROR:  no schema has been selected to create in
: CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 

PG::InvalidSchemaName: ERROR:  no schema has been selected to create in

Tasks: TOP => db:migrate
(See full trace by running
ActiveRecord::StatementInvalid: PG::InvalidSchemaName: ERROR:  no schema has been selected to create in
: CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 

PG::InvalidSchemaName: ERROR:  no schema has been selected to create in

Tasks: TOP => db:migrate
(See full trace by running task with --trace) task with --trace)

我不知道如何修复它,欢迎任何想法。
我正在运行Rails 4。
这个错误是因为我最初使用MySQL数据库(工作正常),但后来切换到pgSQL以方便上传到Heroku。现在它既不能在本地主机上工作,也不能在Heroku上工作。

2
这可能对你有所帮助:http://dba.stackexchange.com/questions/106057/error-no-schema-has-been-selected-to-create-in - Shefalee Chaudhary
2
请查看此解决方案:https://dev59.com/IWYq5IYBdhLWcg3wrihD#14286370 - Shefalee Chaudhary
在测试环境中升级gitlab时,我遇到了问题。上面的答案基本上是正确的。在PG数据库上,将public模式的权限强制禁用以防止任何人使用它们始终是一个好策略,这就是我所做的。但是,我没有正确地恢复它们,因此gitlab用户无法使用它们。一旦我通过stackoverflow链接转移了模式的所有权,它就可以工作了。 - Otheus
1个回答

3

当搜索路径中提到的模式不存在时,会出现此错误。您可能已经在数据库配置中配置了模式搜索路径。您可以从配置中删除模式搜索路径。如果您想保留模式搜索路径,请先创建模式。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接