RubyNewbie
RubyNewbie

Reputation: 547

Heroku DB Push Error / Taps Serve

I am having an issue with Heroku in regards to adding an integer column to an existing table.

Here is how I setup my migration file:

class AddFieldsToNetwork < ActiveRecord::Migration
  def self.up
    add_column :networks, :phone, :integer, :limit => 10
    add_column :networks, :contact, :string
  end

def self.down
  remove_column :networks, :phone
  remove_column :networks, :contact
  end
 end

Now this works locally, but when I push to Heroku, I get what most people get:

!!! Caught Server Exception  
HTTP CODE: 500  
Taps Server Error: PGError: ERROR:  integer out of range

If I change :integer to :string, then adding the columns works and functions great on Heroku. If I leave it under :integer, the :network model crashes when I create new "network".

Can anyone tell me what I might be doing wrong?

Upvotes: 0

Views: 175

Answers (1)

Alisher Ulugbekov
Alisher Ulugbekov

Reputation: 2179

:limit - Requests a maximum column length. This is number of characters for :string and :text columns and number of bytes for :binary and :integer columns.

For phone you definitely use strings, reason is you mean 10 characters. Not bytes for numbers

Upvotes: 1

Related Questions