我有一个似乎导致问题的布尔字段。当我运行时heroku run rake db:reset
,我得到这个结果:
rake aborted!
PGError: ERROR: syntax error at or near "("
LINE 1: ...her_email" character varying(255), "admin" boolean(255) DEFA...
^
: CREATE TABLE "users" ("id" serial primary key, "name" character varying(255), "email" character varying(255), "other_email" character varying(255), "admin" boolean(255) DEFAULT 'f', "password_digest" character varying(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "auth_token" character varying(255), "password_reset_token" character varying(255), "password_reset_sent_at" timestamp, "plant_id" integer, "invoice" boolean)
这是有问题的迁移:
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :other_email
t.boolean :admin, :default => false, :null => false
t.string :password_digest
t.timestamps
end
end
end
我不确定为什么将字段长度添加到布尔字段中。有没有办法覆盖这种行为?