# Migration with Dynamic Table Names?

**URL:** <https://www.ruby-forum.com/t/migration-with-dynamic-table-names/50070>\
**Category:** Ruby\
**Created:** [December 12, 2005, 8:49pm UTC](https://www.ruby-forum.com/t/migration-with-dynamic-table-names/50070 "2005-12-12T20:49:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 12, 2005, 8:49pm UTC](https://www.ruby-forum.com/t/migration-with-dynamic-table-names/50070/1 "2005-12-12T20:49:31Z")

</div>

(This is my first real Ruby/Rails project, so please bare with me…)

I am working on a project that, effectively, has the following database  
structure:

A master table:  
Projects  
- id  
- project\_name  
- etc…

Many slave tables:  
\<project\_name\>\_data  
- id  
- data\_field (several)

So, instead of having one “slave data” table, we have many tables.  
There are a variety of historical and practical reasons for this that,  
while a less than ideal db structure, is needed in this case. Projects  
will come and go, so new names will be created all of the time.

The slave tables will all have the same structure, so the same model  
can be used (Slave\_data, let’s say). I understand that I’ll need to  
use set\_table\_name - I’m just not sure _where_ to use it. I’m assuming  
somewhere within the parent’s model - but I’m a little iffy on the  
details.

I guess they’ll need to be something in or around the “has\_many  
:slave\_data” type line?

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 12, 2005, 9:46pm UTC](https://www.ruby-forum.com/t/migration-with-dynamic-table-names/50070/2 "2005-12-12T21:46:41Z")

</div>

removed\_email\_address@domain.invalid wrote:

> (This is my first real Ruby/Rails project, so please bare with me…)

You may have better luck on the Rails mailing list:

[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

James

–

[http://www.ruby-doc.org](http://www.ruby-doc.org) - Ruby Help & Documentation  
[Ruby Code & Style](http://www.artima.com/rubycs/) - Ruby Code & Style: Writers wanted  
[http://www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff  
[http://www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys  
[http://www.30secondrule.com](http://www.30secondrule.com) - Building Better Tools
