# How make this migration:

**URL:** <https://www.ruby-forum.com/t/how-make-this-migration/104245>\
**Category:** Rails\
**Created:** [May 15, 2007, 10:04pm UTC](https://www.ruby-forum.com/t/how-make-this-migration/104245 "2007-05-15T22:04:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [May 15, 2007, 10:04pm UTC](https://www.ruby-forum.com/t/how-make-this-migration/104245/1 "2007-05-15T22:04:31Z")

</div>

How make this table with migraition:

1. CREATE TABLE Protutos (
2. empresa\_id BIGINT NOT NULL,
3. codigo BIGINT NOT NULL AUTO\_INCREMENT,
4. descricao VARCHAR (50) NOT NULL,
5. PRIMARY KEY(empresa\_id,codigo)
6. ) TYPE = MyISAM

Without field ID outo\_increment  
With type MyISAM  
With two primary keys

And how work this model? How made for working with Finds?

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [May 15, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/how-make-this-migration/104245/2 "2007-05-15T22:18:49Z")

</div>

On 15 May 2007, at 16:04, Marcelo J. wrote:

> With type MyISAM  
> With two primary keys
> 
> And how work this model? How made for working with Finds?

Most rails developers avoid composite primary keys wherever possible.  
Rails is not designed to work with them, but you might like to check  
out:

[http://compositekeys.rubyforge.org/](http://compositekeys.rubyforge.org/)

James.

–  
James S.

> **[Processing Greenbelt 2009](https://jystewart.net/2009/09/08/processing-greenbelt-2009/)**
>
> We did, in fact, make a newspaper. The hour or so after my last post were more than a little stressful, but the results (a few typos and a printing hiccup that most certainly wasn’t our fault…

---

<div class="post-metadata">

**Author:** ![mr\_brownstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@mr\_brownstone](https://www.ruby-forum.com/u/mr_brownstone)\
**Post date:** [May 15, 2007, 10:34pm UTC](https://www.ruby-forum.com/t/how-make-this-migration/104245/3 "2007-05-15T22:34:50Z")

</div>

1. You’ll need a plugin to support composite primary keys. Rails  
won’t give you that. I would recommend designing without the need for  
them. As would most other documentation on Rails will also advise.  
You life will be much more pleasant. This is true for any object-  
relational system. Object need to have identity. A simple integer PK  
is the best way to give them that identity.

2. Rails generally uses InnoDB instead of MyISAM. I highly  
recommended this myself!

3. BIGINT is not a supported type for standard migration code. Look  
into using “execute” within your migration to define your table when  
using database specific schemas. The “common” Rails migration code is  
designed to be database agnostic so it support the most common  
features that are available to all supported databases.

On May 15, 4:04 pm, Marcelo J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
