为什么我的 Rails 'db/schema.rb' 函数前面有 'public'?

Why is my Rails `db/schema.rb` prefixing functions with `public`?

提问人:Chris LaBarge 提问时间:12/28/2020 最后编辑:EyeslandicChris LaBarge 更新时间:12/28/2020 访问量:720

问:

使用 从转储文件重建我的 Postgresql 数据库后,我的模式文件现在在函数前面加上 。pg_restoredb/schema.rbgen_random_uuid()public

create_table "cars", id: :uuid, default: -> { "public.gen_random_uuid()" }

如何防止模式文件在方法调用前面加上 ?public

Ruby-on-Rails PostgreSQL

评论


答:

-3赞 Vi. 12/28/2020 #1

尝试添加环境的配置文件,例如 (在要转储的项目中),然后在本地环境中再次转储和还原数据库。config.active_record.dump_schema_after_migration = false#config/environments/production.rb

评论

0赞 Chris LaBarge 12/29/2020
这对我不起作用,因为我需要在运行时创建/更新db/schema.rbrails db:migrate
0赞 Manuel van Rijn 12/22/2023 #2

我认为问题不在于 rails 的具体问题,而在于具体问题。如果您读取转储,它可能会创建带有前缀的函数?pg_dumppublic.

这里有一个类似的问题,可能会对你有所帮助:如何强制pg_dump(不)包含 DDL 中每个对象的方案名称