# Add an auto-increment column with rake?

**URL:** <https://www.ruby-forum.com/t/add-an-auto-increment-column-with-rake/144158>\
**Category:** Rails\
**Created:** [July 25, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/add-an-auto-increment-column-with-rake/144158 "2008-07-25T23:40:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [July 25, 2008, 11:40pm UTC](https://www.ruby-forum.com/t/add-an-auto-increment-column-with-rake/144158/1 "2008-07-25T23:40:44Z")

</div>

Hi -

for some reason when I was learning Rails, I thought it would be a  
good idea to drop the id from a table. I have no idea why I did it,  
but now I’d like it back. I can roll all the way back, but I don’t  
want to lose my data if at all possible. Is there a way to add an  
auto\_increment column to a table, and secondly, can I do it and have  
all of the id’s automatically filled in on existing data?

Thanks,  
Dino
