# First step for a legacy db

**URL:** <https://www.ruby-forum.com/t/first-step-for-a-legacy-db/134261>\
**Category:** Rails\
**Created:** [April 9, 2008, 11:29am UTC](https://www.ruby-forum.com/t/first-step-for-a-legacy-db/134261 "2008-04-09T11:29:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 9, 2008, 11:29am UTC](https://www.ruby-forum.com/t/first-step-for-a-legacy-db/134261/1 "2008-04-09T11:29:36Z")

</div>

what’s the first step for the migration of a legacy db such as:

mysql\>  
mysql\> SHOW TABLES;  
±------------------------+  
| Tables\_in\_feed\_on\_feeds |  
±------------------------+  
| fof\_feed |  
| fof\_item |  
| fof\_item\_tag |  
| fof\_subscription |  
| fof\_tag |  
| fof\_user |  
±------------------------+  
6 rows in set (0.00 sec)

mysql\>  
mysql\> DESCRIBE fof\_feed;  
±------------------------±--------±-----±----±--------  
±---------------+  
| Field | Type | Null | Key | Default |  
Extra |  
±------------------------±--------±-----±----±--------  
±---------------+  
| feed\_id | int(11) | NO | PRI | NULL |  
auto\_increment |  
| feed\_url | text | NO | |  
| |  
| feed\_title | text | NO | |  
| |  
| feed\_link | text | NO | |  
| |  
| feed\_description | text | NO | |  
| |  
| feed\_image | text | YES | | NULL  
| |  
| feed\_image\_cache\_date | int(11) | YES | | 0  
| |  
| feed\_cache\_date | int(11) | YES | | 0  
| |  
| feed\_cache\_attempt\_date | int(11) | YES | | 0  
| |  
| feed\_cache | text | YES | | NULL  
| |  
±------------------------±--------±-----±----±--------  
±---------------+  
10 rows in set (0.00 sec)

mysql\>  
mysql\>

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 10, 2008, 11:33pm UTC](https://www.ruby-forum.com/t/first-step-for-a-legacy-db/134261/2 "2008-04-10T23:33:53Z")

</div>

Thufir,

When you define your models and associations between them, you can  
override the defaults that Rails uses. Rails adopts the Convention  
over Configuration paradigm, but also includes all the configuration  
hooks you’d need.

So, for example, the convention is that the primary key is a field  
called “id” and is autogenerated. Instead, you’d tell the fof\_feed  
model to use “feed\_id” as the id.

# class FofFeed \< ActiveRecord::Base

# set\_primary\_key “feed\_id”

# end

# 

# # You still use the id method to access this value

# f = FofFeed.create

# f.id

If you look at the API docs for ActiveRecord::Base you’ll find these  
configuration options.

That should get you started. 🙂

-Danimal
