我对 postgres 8.4 上的默认修饰符有疑问。(我认为版本并不重要)我有 debian ubuntu。当我在 Rails AR 上创建迁移时:
class CreateUserMails < ActiveRecord::Migration
def self.up
create_table :user_mails do |t|
t.string :title, :limit=> 128, :default=> ''
t.string :place, :limit=> 32, :default=> ''
t.text :message
t.timestamps
end
end
def self.down
drop_table :user_mails
end
end
在 postgres 上它看起来像这样:
Column | Type | Modifiers
--------------+-----------------------------+---------------------------------------------------------
id | integer | not null default nextval('user_mails_id_seq'::regclass)
title | character varying(128) | default ''::character varying
place | character varying(32) | default ''::character varying
message | text |
created_at | timestamp without time zone |
updated_at | timestamp without time zone |
没有在控制台上作为默认值我得到
um = UserMail.new => #UserMail id: nil, title: "''::character varying", place: "''::character varying", message: nil, created_at: nil, updated_at: nil
有谁知道我如何删除这些修饰符并只保留''或任何默认值而不保留:::character 变化?