# Migration

**URL:** <https://www.ruby-forum.com/t/migration/86342>\
**Category:** Engines\
**Created:** [March 23, 2006, 10:04pm UTC](https://www.ruby-forum.com/t/migration/86342 "2006-03-23T22:04:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [March 23, 2006, 10:04pm UTC](https://www.ruby-forum.com/t/migration/86342/1 "2006-03-23T22:04:12Z")

</div>

Hello,

I’m trying to learn good habits and use migration along with my very  
first steps with RoR and Engines.

I have few questions for the advanced users of Engines :

1. Generating the migrate files

- I cd in my engine dir, then /absolutepath\_to\_ror\_app/script/generate  
migration AddCommentsTable
- script complains about db directory not existing
- mkdir db
- /absolutepath\_to\_ror\_app/script/generate migration AddCommentsTable  
again
- migrate file is generated in my app root/db directory not inside the  
engine !

1. No matter, I mv the migrate file inside engine/db

- rake migrate\_engine ENGINE=publish
- rake creates schema info and engine schema info but the content of the  
migrate file is not executed (or if it is, it doesn’t produce the  
expected result)

To get generated schema into MySQL, I need to migrate and rake into the  
root app dir, not inside the engine

Obviously, there is something wrong but I don’t understand the reason…

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [March 23, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/migration/86342/2 "2006-03-23T22:35:36Z")

</div>

Got it working, maybe the problem was caused by previous failed tries or  
manual alteration of the db (without reseting version table)

But point 1) is still true - But quite harmless

---

<div class="post-metadata">

**Author:** ![chriscole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/5fc32e/32.png) [@chriscole](https://www.ruby-forum.com/u/chriscole)\
**Post date:** [April 9, 2006, 9:34pm UTC](https://www.ruby-forum.com/t/migration/86342/3 "2006-04-09T21:34:17Z")

</div>

At the moment you cannot generate migrations directly into an Engine -  
instead, you can either create them by hand (which isn’t hard once you  
know what you’re doing), or generate them in the Rails application and  
copy them over (making sure that they are numbered appropriately).

Also - Rake tasks must always be run from RAILS\_ROOT.

- james

On 3/23/06, Christophe G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~
