I am trying to setup a Rails app on Heroku using PG, and also using devise and oauth to interact with the Yahoo Sports api.
I am running into an issue where when the users goes to authenticate the Heroku logs are telling me:
ActiveRecord::StatementInvalid (PG::Error: ERROR: value too long for type character varying(255)
So after reading this Stack Overflow post PostgreSQL string(255) limit – Rails, Ruby and Heroku, I tried changing the token to text from string since that seemed to be the longest thing that may be causing the over 255 limit. My migration looked like this:
class AddAccessTokenToAuthentications < ActiveRecord::Migration
def change
add_column :authentications, :token, :text, :limit => nil
add_column :authentications, :secret, :string
end
end
However for some reason it seems to be changing everything to text. When I look at my schema after migrating it shows:
create_table "authentications", :force => true do |t|
t.integer "user_id"
t.text "provider", :limit => 255
t.text "uid", :limit => 255
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "token", :limit => 255
t.text "secret", :limit => 255
end
When I push to Heroku and try to migrate on Heroku I am getting this error:
-- create_table("authentications", {:force=>true})
NOTICE: CREATE TABLE will create implicit sequence "authentications_id_seq" for serial column "authentications.id"
rake aborted!
PG::Error: ERROR: type modifier is not allowed for type "text"
LINE 1: ...serial primary key, "user_id" integer, "provider" text(255),...
: CREATE TABLE "authentications" ("id" serial primary key, "user_id" integer, "provider" text(255), "uid" text(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "token" text(255), "secret" text(255))
I am not sure how to resolve this or what I should be looking into.
means you can’t use
:limitWhat you can do is either:
or