【问题标题】:Rails (PostgreSQL?) implicit sequence/index warning [duplicate]Rails(PostgreSQL?)隐式序列/索引警告[重复]
【发布时间】:2012-08-17 10:05:17
【问题描述】:

可能重复:
NOTICES for sequence after running migration in rails on postgresql Application

将 PostgreSQL 用于开发和测试数据库(以及生产)。当我 rake db:test:prepare 我的 PostgreSQL theapp_test 数据库时,我会收到每个表的这些消息:

NOTICE:  CREATE TABLE will create implicit sequence "events_id_seq" for serial column "events.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "events_pkey" for table "events"
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users"
...

我在theapp_development 上没有收到rake db:migrate 的这些通知。而且我还没有在生产中注意到它们。这是什么意思,我应该努力摆脱它们吗?

仅供参考 - 过去我使用 MySQL(或 SQLite3)进行测试时不会发生这种情况......

【问题讨论】:

  • -1,因为它与通过搜索错误消息在相同标签中轻松找到的问题重复。
  • 我在发帖前搜索了 3 种不同的方式。一定错过了。对不起。发生。
  • @Meltemi np,对不起。值得一提的是您在帖子中尝试/查看的内容。 -0.

标签: ruby-on-rails postgresql migration database-migration


【解决方案1】:

没有。这只是 Postgres 很棒,它会自动为你创建你真正想要的东西。这不是警告,只是仅供参考

【讨论】:

  • 没有自动索引 PK 真的很麻烦.. 我会说“做它应该做的”(或“做我期望 SQL Server 做的”;-) vs “真棒" .. pgsql 只是对此事更加冗长。
  • +1 用于指出是 NOTICE(又名“信息”)而不是警告..
【解决方案2】:

您可以通过在config/database.yml 中添加(或取消注释)一行来使这些消息静音:

# config/database.yml
development:
  adapter: postgresql
  min_messages: WARNING  # this line silences those NOTICE messages

【讨论】:

    猜你喜欢
    • 2015-08-21
    • 1970-01-01
    • 1970-01-01
    • 2012-04-04
    • 2019-11-29
    • 1970-01-01
    • 2015-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多