Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 353
giuseppe Avatar asked Mar 09 '12 10:03

giuseppe


People also ask

What is doctrine migration?

The Doctrine Migrations project offers additional functionality on top of the DBAL and ORM for versioning your database schema. It makes it easy and safe to deploy changes to it in a way that can be reviewed and tested before being deployed to production.

What is migration Symfony?

Database migrations are a way to safely update your database schema both locally and on production. Instead of running the doctrine:schema:update command or applying the database changes manually with SQL statements, migrations allow to replicate the changes in your database schema in a safe manner.


2 Answers

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) 
like image 150
Julio Avatar answered Oct 17 '22 07:10

Julio


I saw this doc on Symfony's website : http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html#usage

There is doctrine:migrations:execute that allows you to execute a single migration version up or down manually... but never tried, sorry.

Hope this helps !

Keep us posted.

like image 42
Aurel Avatar answered Oct 17 '22 09:10

Aurel