Doctrine2 migrations migrate down and migrate from browser and not command line

giuseppe picture giuseppe · Mar 9, 2012 · Viewed 61.6k times · Source

I am using Doctrine2 migrations. I need some answers about my doubt, I canno find a good solution in documentations

I use:

  doctrine migrations:diff // generate migrations files
  doctrine migrations:migrate // migrates up to new version
  1. How Can I migrate down? specifying the previous version did not work ( nothing to update it says f.e. doctrine migrations:migrate Version20120211163332 it says

    Migrating up to Version20120211163332 from 20120309112058
    
    [Doctrine\DBAL\Migrations\MigrationException]  
    Could not find any migrations to execute.      
    

    But it's not up it should be down! you can see also on versions in response

  2. If I have to make some DB update, is it possible to add some SQL Queries in additions ( alter some datas related to other) ? I have not tried still since the down is not working :((

  3. Is there any way to use the migrate command in a browser nutshell ? I have sw in a shared hosting without console access so I need this feature, instead of copying queries one by one :D in phpMyAdmin

Answer

Julio picture Julio · Dec 21, 2012

You can optionally manually specify the version you wish to migrate to:

 php doctrine.php migrations:migrate YYYYMMDDHHMMSS

or execute a migration up/down

php doctrine.php migrations:execute YYYYMMDDHHMMSS  --down
php doctrine.php migrations:execute YYYYMMDDHHMMSS  --up

You can found YYYYMMDDHHMMSS using:

php doctrine.php migrations:status
>> Current Version:           2012-12-20 23:38:47 (20121220233847)
>> Latest Version:            2012-12-20 23:38:47 (20121220233847)