# A bug with script/generate plugin\_migrations?

**URL:** <https://www.ruby-forum.com/t/a-bug-with-script-generate-plugin-migrations/93031>\
**Category:** Engines\
**Created:** [April 26, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/a-bug-with-script-generate-plugin-migrations/93031 "2007-04-26T19:35:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trevor\_Rowe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@Trevor\_Rowe](https://www.ruby-forum.com/u/Trevor_Rowe)\
**Post date:** [April 26, 2007, 7:35pm UTC](https://www.ruby-forum.com/t/a-bug-with-script-generate-plugin-migrations/93031/1 "2007-04-26T19:35:14Z")

</div>

I tried searching the mailing list for an answer with no luck. I’m  
hoping this is just user error:

I recently upgraded my rails app to Rails 1.2.3 (from Rails 1.1.6) and  
upgraded to engines 1.2 at the same time. I ran script/generate  
plugin\_migrations for the first time and it created an application  
migration would run my plugin migration from 0-45 (as expected).

I added a new migration to my plugin, ran the script/generate  
plugin\_migration again and it added a second application migration, but  
in the down method it migrates to version 0 instead of version 45 as I  
would have expected. Any ideas on what I could be doing wrong? I  
checked the db and the plugins\_schema\_info table has my plugin currently  
at version 45 and my application at 1. Any suggestions would be  
helpful.

Trevor Rowe

---

<div class="post-metadata">

**Author:** ![Trevor\_Rowe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@Trevor\_Rowe](https://www.ruby-forum.com/u/Trevor_Rowe)\
**Post date:** [April 27, 2007, 10:40am UTC](https://www.ruby-forum.com/t/a-bug-with-script-generate-plugin-migrations/93031/2 "2007-04-27T10:40:28Z")

</div>

Hi Trevor,The most common reason for this would be that you  
plugin\_schema\_info version for the plugin was still 0 when you ran  
script/generate plugin\_migration for the second time. Can you confirm  
that you did run rake db:migrate between generating the first plugin  
migration and the second?

---

<div class="post-metadata">

**Author:** ![Trevor\_Rowe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/d78d45/32.png) [@Trevor\_Rowe](https://www.ruby-forum.com/u/Trevor_Rowe)\
**Post date:** [April 27, 2007, 5:36pm UTC](https://www.ruby-forum.com/t/a-bug-with-script-generate-plugin-migrations/93031/3 "2007-04-27T17:36:32Z")

</div>

I did some more digging. I had run the migration already for my local  
development environment, but curiously enough I went to test this again  
today and here is what I noticed:

I built a new plugin migration and tried to run script/generate  
plugin\_migration and I got an error that said I couldn’t connect to the  
db. My development db is on localhost, and I realized then it was  
connecting to the production db to get information on what migration it  
should run.

Is there a way to set the environment?

I tried adding the environment as -e, --environment, RAILS\_ENV=, just  
adding the environment name, etc, no luck. This would explain my  
previous problem, the migration had been run, just not against my  
production environment yet.

Any suggestions?

Trevor
