当我在 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_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
我想知道
这个通知是什么意思?
如何避免此通知?
如果不避免此类通知,会对应用程序产生什么影响?
问候,
萨利尔
最佳答案
Rails(更准确地说是 ActiveRecord)正在向您的表中添加一个 id
列,并使该列成为主键。对于 PostgreSQL,此列的类型为 serial
。 serial
column本质上是一个四字节整数,结合一个序列以自动提供自动递增的值。
第一条通知:
NOTICE: CREATE TABLE will create implicit sequence "notification_settings_id_seq" for serial column "notification_settings.id"
只是告诉您 PostgreSQL 正在幕后创建序列以使 serial
列起作用。
第二条通知:
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "notification_settings_pkey" for table "notification_settings"
只是告诉你 PostgreSQL 正在创建一个索引来帮助实现主键,即使你没有明确要求它这样做。
您可以忽略这些通知,它们只是提供信息。如果你想抑制它们,你可以添加 min_messages: WARNING
到 database.yml
的适当部分。
关于ruby-on-rails - 在 postgresql 应用程序的 rails 中运行迁移后的序列通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5296290/