Ruby on rails 在postgresql应用程序上运行rails迁移后的顺序注意事项
当我在postgresql上运行我的Rails迁移应用程序时,我收到了以下通知Ruby on rails 在postgresql应用程序上运行rails迁移后的顺序注意事项,ruby-on-rails,ruby,postgresql,database-migration,Ruby On Rails,Ruby,Postgresql,Database Migration,当我在postgresql上运行我的Rails迁移应用程序时,我收到了以下通知 NOTICE: CREATE TABLE will create implicit sequence "notification_settings_id_seq" for serial column "notification_settings.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "notification_setti
NOTICE: CREATE TABLE will create implicit sequence "notification_settings_id_seq" for serial column "notification_settings.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "notification_settings_pkey" for table "notification_settings"
我的迁移文件包含088_create_notification_settings.rb
class CreateNotificationSettings < ActiveRecord::Migration
def self.up
create_table :notification_settings do |t|
t.integer :user_id
t.integer :notification_id
t.boolean :notification_on
t.boolean :outbound
end
end
def self.down
drop_table :notification_settings
end
end
class CreateNotificationSettings
我想知道
这是什么意思
如何避免这种情况
如果不能避免,这些通知会对申请产生什么影响
问候,
SalilRails(更准确地说是ActiveRecord)正在向表中添加一个id
列,并使该列成为主键。对于PostgreSQL,此列的类型为serial
。A本质上是一个四字节整数,与一个序列相结合,以自动提供自动递增的值
第一个通知:
注意:创建表将为序列列“notification\u settings.id”创建隐式序列“notification\u settings\u id\u seq”
只是告诉你PostgreSQL正在幕后创建一个序列来实现serial
列函数
第二项通知:
注意:创建表/主键将为表“通知设置”创建隐式索引“通知设置”
只是告诉您PostgreSQL正在创建一个索引来帮助实现主键,即使您没有明确要求它
你可以忽略这些通知,它们只是信息。如果要抑制它们,可以添加到
数据库的相应部分。yml
通知与序列的创建以及Postgresql在id列上创建自动增量的方式有关
回答其他问题:
如何避免通知
在database.yml文件中,只需包含
MINU信息:警告#魔术酱
如果忽略通知,会对应用程序产生什么影响
基本上,它将增加日志记录,特别是在开发模式下运行时
除mu所说的内容外,更多详情请参见: 如果您不想看到这些通知,可以通过将“客户端\最小\消息”设置为“警告”(或“错误”)来关闭它们 这可以在会话级别上完成,使用
set client\u min\u messages=warning
或在服务器的所有连接的配置文件中:
我希望我能接受不止一个答案,但由于我不能接受,我只能给你投票。对于通过自制安装的postgresql 9.2,你需要编辑/usr/local/var/postgres/postgresql.conf并设置
client\u min\u messages=warning
,database.yml设置似乎不起作用。@weston:你在database.yml
中尝试了什么?好吧,它应该还能工作,但我没有设置9.2来检查。