问题描述
Haven已经有一段时间没有与Postgres一起工作了,而我在一个刚开始使用的现有项目中遇到了这个问题。
Haven't worked with postgres in a while and I'm running into this issue on an existing project I've just started working with.
当我运行 rails g migration
时,命令成功完成;但是,它会在 db / structure.sql
上生成大量差异。区别在于修订后的文件在每个命令前都显式地加上了postgres公共模式。
When I run rails g migrate
, the command completes successfully; however, it generates a boatload of diffs on db/structure.sql
. The differences are that the revised file explicitly prefixes every command with the postgres public schema.
例如,我得到了许多这样的差异:
-CREATE TABLE客户(
+ CREATE TABLE public.customer(
For example, I get many diffs like this:-CREATE TABLE customer (+CREATE TABLE public.customer (
我抑制了这种行为?
推荐答案
这至少是由Postgresql 9.4.17中的一个安全补丁引起的。 = https://bucardo.org/postgres_all_versions.html#version_9.4.17 rel = noreferrer>从3月1日起发布(其他版本也可能受到影响),从而更改了<$ c的行为$ c> search_path 使用 $ pg_dump
时。
This looks to be caused by the a security patch in at least Postgresql 9.4.17 release from the 1st March (other versions may also be affected), which changed the behaviour of search_path
when using $ pg_dump
.
您可以尝试将其降级为以前的补丁程序版本(例如 9.4.16
),可以保留以前的行为,或者尝试并使用此新版本更新架构。
You could try either downgrading to the previous patch version (e.g. 9.4.16
), which preserves the previous behaviour, or take the plunge and update your schema using this new version.
这篇关于rails g使用带有模式名称的postgres前缀命令迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!