I am trying to import existing data from 2 tables into a rails app, and having a strange issue related to ids. All the migrations creating the tables seem to adhere to conventions (no specific mention of id field, just leaving that to rails to figure out). Basically I am sending in an ajax object for each object in table A, which belongs to an object in table B. I have a field in object A called object_b_name, and a mutator method that does a find_or_create_by_name based on object_b_name, returning object B's id to use in object A.
On my local server, the objects in table B have consecutive ids. But on the remote server, running the same code, those objects all have id 0. What would cause this?
Edit/Update: Upon inspecting the schema in the remote server, it turned out that there was no auto-increment or index on the id field (as @Sammitch mentioned), so I'm guessing someone else on the project created that table manually for some reason. Adding those constraints resolved the issue.
idcolumn on the remote server has neither a unique key/index, norAUTO_INCREMENTdefined on it.