Sal*_*lil 34 ruby postgresql ruby-on-rails 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_settings_pkey" for table "notification_settings"
Run Code Online (Sandbox Code Playgroud)
我的迁移文件包含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
Run Code Online (Sandbox Code Playgroud)
我想知道
这个通知意味着什么?
如何避免这种通知?
如果不避免,此类通知对应用程序的影响是什么?
问候,
萨里尔
mu *_*ort 77
Rails(ActiveRecord更精确)是id在表中添加一列,并使该列成为主键.对于PostgreSQL,此列将具有类型serial.甲serial柱基本上是一个4个字节整数用序列结合以自动提供自动递增值.
第一个通知:
注意:CREATE TABLE将为串行列"notification_settings.id"创建隐式序列"notification_settings_id_seq"
只是告诉你PostgreSQL正在幕后创建一个序列来使serial列功能.
第二个通知:
注意:CREATE TABLE/PRIMARY KEY将为表"notification_settings"创建隐式索引"notification_settings_pkey"
只是告诉你PostgreSQL正在创建一个索引来帮助实现主键,即使你没有明确要求它.
你可以忽略这些通知,它们只是信息性的.如果你想抑制它们,你可以添加min_messages: WARNING到你的相应部分database.yml.
除了mu所说的:
如果您不想看到这些通知,可以通过将client_min_messages设置为警告(或错误)来关闭它们.
这可以在会话级别上完成,使用set client_min_messages = warning或在服务器的配置文件中为所有连接:
| 归档时间: |
|
| 查看次数: |
5320 次 |
| 最近记录: |