A bug with script/generate plugin_migrations?

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

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?

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