# Migrations in current dir, not RAILS\_ROOT

**URL:** <https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664>\
**Category:** Rails\
**Created:** [November 15, 2005, 11:43am UTC](https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664 "2005-11-15T11:43:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [November 15, 2005, 11:43am UTC](https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664/1 "2005-11-15T11:43:56Z")

</div>

I’m playing around with engines, and want to see if I can get  
migrations working with them. According to rake --tasks, the migrate  
task will “migrate the database according to the migrate scripts in  
db/migrate (only supported on PG/MySQL).” I assumed it would just  
look in the current dir for db/migrate, but it doesn’t seem to be.  
Here’s the layout of my app:  
myproject  
|- db  
|- migrate  
|- vendor  
|- plugins  
|- myengine  
|- db  
|- migrate

if I cd to vendor/plugins/myengine and run “rake migrate”, it ignores  
the files in ./db/migrate. However if I copy them up to  
myproject/db/migrate, it finds them fine. So my first question is how  
does rake know to use RAILS\_ROOT to begin with? I don’t see any  
reason why it wouldn’t act in the current directory. Second, how do I  
get it to run migrate on the migrations beneath the current directory?

Thanks,  
Pat

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [November 15, 2005, 12:14pm UTC](https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664/2 "2005-11-15T12:14:07Z")

</div>

Running migrations from external code sources is going to involve a  
LOT of trust. I can see how the workflow might ideally be very  
convenient, but I would _strongly_ suggest that it’s better for you to  
have all of the migrations stuff under your total control.

It’s not that I’m saying you absolutely shouldn’t… just that when  
you’re actually talking about your DB, the precious data in the middle  
of your Totally Sweet Rails App, I wouldn’t trust _anyone_ to screw  
around with the schema at all.

In other words, the DB schema provided with engines should only really  
be used for bootstrapping and for reference, and manually integrating  
it with your existing migrations will probably make your life much  
easier in the long-term. DB schemas shouldn’t change between minor  
versions of engines (or any code that is in beta), so if you stick to  
a single release of, say, the login engine, you shouldn’t have to deal  
with schema changes, ever (oh, for an ideal world…).

- james

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [November 17, 2005, 10:47am UTC](https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664/3 "2005-11-17T10:47:27Z")

</div>

Pat, you might want to check out the migrations stuff that I just  
added to the developer branch of Engines; I posted to the list  
yesterday about it. Very much inspired by your conversation on IRC 🙂

- james

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [November 15, 2005, 12:29pm UTC](https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664/4 "2005-11-15T12:29:12Z")

</div>

I was thinking more like using migrations to manage the database as  
the app progresses…but if I’m just working on the engine, then  
obviously I don’t need to upgrade any schemas, so I’m free to just  
wipe the db as necessary.

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [November 17, 2005, 11:11am UTC](https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664/5 "2005-11-17T11:11:35Z")

</div>

I saw the announcement, thanks for putting it up. That wasn’t you I  
was talking with, was it? I’d feel pretty stupid referring to “James  
Adam” if I was speaking with you 🙂

Anyway I’ll mess around with it, see if there are any problems.

Any clue about the problem with the LoginEngine not rolling back  
changes when an email can’t be delivered? I spent a long time trying  
to figure out why that test was failing and am just stumped.

Pat

---

<div class="post-metadata">

**Author:** ![pergesu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/22d042/32.png) [@pergesu](https://www.ruby-forum.com/u/pergesu)\
**Post date:** [November 17, 2005, 11:29am UTC](https://www.ruby-forum.com/t/migrations-in-current-dir-not-rails-root/48664/6 "2005-11-17T11:29:48Z")

</div>

I’m “lazyat0m”, normally, so no - I was lurking 😉

I’m still stumped by that issue - when I try working with it in the  
console, the roll-back happens, but it just never seems to work when  
testing! :-S

- james
