I am working on my app (Rails 3.2, PostgreSQL 9.1) on localhost and everything works me well there, so I decided to deploy the app to the production to Heroku.
After successful deployment of the app I tried to create a new item and got this error message:
ActiveRecord::StatementInvalid (PG::Error: ERROR: null value in column "persistence_token" violates not-null constraint
It’s about the table Users (use Authlogic gem). This is the sample of migration – critical part:
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name, :null => false
t.string :email, :null => false
t.string :crypted_password, :default => nil, :null => true
t.string :password_salt, :default => nil, :null => true
t.string :email, :default => nil, :null => true
t.string :persistence_token, :null => false
t.string :single_access_token, :null => false
t.string :perishable_token, :null => false
t.datetime :last_request_at
t.datetime :current_login_at
t.datetime :last_login_at
t.string :current_login_ip
t.string :last_login_ip
t.timestamps
end
end
end
What could caused this problem? I mean, I see in the migration is the rule :null => false and the error message says about the null value saved into this column, but how is possible on localhost this work well and on Heroku not?
And, how could I fix that? My first idea was to create a new migration, where I set up for that column :null => true, but is it correct?
I set up the default value to
DEFAULT ''and the error is gone…