Running Phinx Migrations on Heroku

Phinx is an awesome tool for creating database migrations using PHP. Kind of like Rake for Ruby.

The documentation is fairly straightforward for development use, as well as for use cases where you would add your database credentials directly to the config file (though I can’t think of a good use case for that!).

To check if migrations have been executed in, say, your local environment, you’d run the following command:

vendor/bin/phinx status -e development

Being new to Heroku, however, I got stuck trying to do the same from the CLI. I tried this:

heroku run phinx status -e staging

However, Phinx responded with the following (edited to remove my Heroku URL):

!    env flag staging appears invalid. Avoid using ';' in values.
 Running phinx status on whispering-tor-79505… starting, run.2374 (Free)
 Running phinx status on whispering-tor-79505… connecting, run.2374 (Free)
 Running phinx status on whispering-tor-79505… up, run.2374 (Free)
 Phinx by CakePHP - https://phinx.org. 0.10.8

 using config file ./phinx.php
 using config parser php
 using migration paths
- /app/db/migrations
 warning no environment specified, defaulting to: development Code language: JavaScript (javascript)

As is usually the case, it was operator error. Per the Heroku CLI Documentation — and a big thank you to Edgaras Janušauskas for pointing this out — I was sending the flag incorrectly.

Here’s the proper syntax:

heroku run -- phinx status -e staging

I hope this helps someone else!

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x