在Postgresql Application上的rails中运行迁移后的序列注意事项 [英] NOTICES for sequence after running migration in rails on postgresql Application

查看:77
本文介绍了在Postgresql Application上的rails中运行迁移后的序列注意事项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Postgresql上的Rails应用程序中运行迁移时,我遵循了通知

When i run my migration in Rails application on postgresql i got following NOTICES

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

My migration file contains 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

我想知道

此通知是什么意思?

如何避免此通知?

如果不避免,此类通知将对申请产生什么影响?

What will be the impact of such NOTICES on the Application if not avoided?

注意事项

Salil

推荐答案

Rails(更准确地说是ActiveRecord)添加了<表中的code> id 列,并将此列作为主键。对于PostgreSQL,此列的类型为 serial serial 本质上是一个四字节整数,加上一个序列以自动提供自动递增的值。

Rails (ActiveRecord to be more precise) is adding an id column to your table and making this column the primary key. For PostgreSQL, this column will have type serial. A serial column is essentially a four byte integer combined with a sequence to automatically provide auto-incrementing values.

第一个通知:


注意:CREATE TABLE将为序列列 notification_settings.id创建隐式序列 notification_settings_id_seq

NOTICE: CREATE TABLE will create implicit sequence "notification_settings_id_seq" for serial column "notification_settings.id"

只是告诉您PostgreSQL正在幕后创建一个序列以使 serial 列函数。

is just telling you that PostgreSQL is creating a sequence behind the scenes to make the serial column function.

第二条通知:


注意:CREATE TABLE / PRIMARY KEY将为表 notification_settings创建隐式索引 notification_settings_pkey

NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "notification_settings_pkey" for table "notification_settings"

只是告诉您PostgreSQL正在创建索引来帮助实现主键,即使您没有明确要求它。

is just telling you that PostgreSQL is creating an index to help implement the primary key even though you didn't explicitly ask it to.

您可以忽略这些通知,它们只是提供信息。如果要抑制它们,则可以添加 min_messages:警告 database.yml 的相应部分。

You can just ignore these notices, they're just informational. If you want to suppress them, you can add min_messages: WARNING to the appropriate section of your database.yml.

这篇关于在Postgresql Application上的rails中运行迁移后的序列注意事项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆