代码之家  ›  专栏  ›  技术社区  ›  Conor

运行迁移将使schema public前置,以便在structure.sql中创建语句

  •  1
  • Conor  · 技术社区  · 6 年前

    跑步时 $ rails db:migrate ,无论是否添加了任何迁移,structure.sql都将更改删除 SET search_path = public, pg_catalog; 换成 SELECT pg_catalog.set_config('search_path', '', false); 然后准备 public. 对每一个 CREATE 语句。

    例子:

    CREATE FUNCTION round_minutes(timestamp without time zone, integer) RETURNS timestamp without time zone

    变成:

    CREATE FUNCTION public.round_minutes(timestamp without time zone, integer) RETURNS timestamp without time zone

    使用:

    • PostgressQL v10.4版
    • Rails 5.2.0

    这个问题似乎会影响到我们这些使用9.6.5以上postgres版本的人。

    有没有办法配置postgres不这样做?

    1 回复  |  直到 6 年前
        1
  •  3
  •   Reed G. Law    6 年前

    有一个 vulnerability in Postgresql 那是在2018年3月修好的。

    如果您使用的是PostgreSQL 10.3、9.6.8、9.5.12、9.4.17、9.3.22或更高版本,则它将在表引用中指定Pulbic架构,并设置pg_catalog search_路径。

    也许您的团队中有人正在使用旧版本的postgresql,从而导致structure.sql恢复。