lundi 6 avril 2015

Ruby on Rails SQLite3 Table ID numbers

I am practicing with "Rails: Up and Running" book. There is written that database fills id attributes by itself if not added. Here's an example.


some_items.yml:



one:
name: stringOne

two:
name: stringTwo


Ok. Now, I'm making migration and loading data with "rake db:migrate" and "rake db:fixtures:load". Then I am trying to check what table "some_items" contains. While sending SQL query to SQLite3 console I'm receiving output like this:



298486374|stringTwo|2015-04-06 14:00:33|2015-04-06 14:00:33
980190962|stringOne|2015-04-06 14:00:33|2015-04-06 14:00:33


I am wondering is SQLite3 fills ID with random numbers? And if so, why not in normal ascending order like 1, 2, ...? And again - if so, why Rails doesn't create ID attribute in YAML testing files to show it in proper order?


Aucun commentaire:

Enregistrer un commentaire