I need add to id values with 15 digits, it is id from facebook objects and it is not depent on me. First I changed int to string, it works in browser. But in test with capybara it not work, even if I drop, create and migrate test database once more. So next I will change string to integer but with limit 8 (I'm using mysql)
Instead of this, when I tried saved long number in integer I got duplicate entry error from mysql (strange).
But what is the problem when I changed id from int to string, in test (after load schema.rb file) id field in sql query was still like integer and schema.rb file not have any information about id type (string). And after changed id to integer with limit 8, schema.rb didn't have information about this too. It is very bad, because after migration id is big int but after load schema id is only integer
schema.rb are able to create primary key only as integer. it would be grate to support other datatype for primary key
I feel like this is a duplicate, but I just can't find the ticket. :(
I'm not sure if I understand the issue completely. You could try to define the primary key as follows:
class Article < ActiveRecord::Base
self.primary_key = "string_pk"
class CreateArticles < ActiveRecord::Migration
create_table :articles, :id => false do |t|
t.string :string_pk, :primary => true
If this does not help could you please provide a test-case or a sample app with your problem? This would help a lot to investigate the problem. Also, what version of rails do you use?
We havent heard from you in 2 months. Without further information we can't pursue the issue further. I'm closing this for now. Please reopen if the problem still occurs and post more information.