# Can't use models in migrations

**URL:** <https://www.ruby-forum.com/t/cant-use-models-in-migrations/90085>\
**Category:** Rails\
**Created:** [March 25, 2007, 10:38pm UTC](https://www.ruby-forum.com/t/cant-use-models-in-migrations/90085 "2007-03-25T22:38:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [March 25, 2007, 10:38pm UTC](https://www.ruby-forum.com/t/cant-use-models-in-migrations/90085/1 "2007-03-25T22:38:15Z")

</div>

Hi there,

This always used to work for me… but not now. I want to blame Rails  
1.2 but I’m sure its not.

I can’t use AR models in my migrations. To make sure its not just my  
dodgy code I tried to do the same with a well known plugin…  
acts\_as\_versioned.

A migration such as the one below (taken from acts\_as\_versioned) is  
giving the error  
undefined method `create\_versioned\_table’ for  
#ActiveRecord::ConnectionAdapters::MysqlAdapter:0xb74a1d44

What the hell is that about? create\_versioned\_table is a definition of  
Post… not bloody SqlAdapter whatever.

Ideas?

Thanks  
-henry

```
    # class AddVersions < ActiveRecord::Migration
    # def self.up
    # # create_versioned_table takes the same options hash
    # # that create_table does
    # Post.create_versioned_table
    # end
    #
    # def self.down
    # Post.drop_versioned_table
    # end
    # end
```

---

<div class="post-metadata">

**Author:** ![henster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a183cd/32.png) [@henster](https://www.ruby-forum.com/u/henster)\
**Post date:** [March 26, 2007, 8:05pm UTC](https://www.ruby-forum.com/t/cant-use-models-in-migrations/90085/2 "2007-03-26T20:05:13Z")

</div>

Hmmm, as expected I was at fault…

I was giving my migrations the same class names as their respective  
models… madness.

ta  
-h

On Mar 25, 9:37 pm, “Henry T.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
