0

I have a boolean field that seems to be causing issues. When I run heroku run rake db:reset, I get this as a result:

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)

Here's the migration in question:

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

I'm unsure why a field length is being added to a boolean field. Is there a way to override this behavior?

jeffmueller
  • 145
  • 10

1 Answers1

1

Check your schema.rb file, you may find there

t.boolean  "admin", :limit => 255

You can create migration

change_column :users, :admin, :boolean, :limit => nil

I guess you can also add :limit => nil to create_table migration. You may also have to run rake db:migrate in development environment and commit new schema.rb without :limit to production.