[DC-702] Migration commands always want to drop all database tables Created: 25/May/10  Updated: 07/May/12  Resolved: 08/Jun/10

Status: Resolved
Project: Doctrine 1
Component/s: Migrations
Affects Version/s: 1.2.2
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Benjamin Arthur Lupton Assignee: Jonathan H. Wage
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

Zend Server 5.0.1 for OSX, PHP 5.3.2, MySQL 5.1.43



 Description   

I'm trying to get migrations going, such that I install the database, make a change to the schema.yml (something simple such as a column length change), and then have a migration generated and performed.

No matter what I try, doctrine just generates an initial add all the database tables, then after that if I try any further migration generation, they all try to drop all the database tables. I am not having much luck.

$ rm ../application/data/migrations/*

$ php ./doctrine build-all-reload
build-all-reload - Are you sure you wish to drop your databases? (y/n)
y
build-all-reload - Successfully dropped database for connection named '0'
build-all-reload - Generated models successfully from YAML schema
build-all-reload - Successfully created database for connection named '0'
build-all-reload - Created tables successfully
build-all-reload - Data was successfully loaded

$ ls ../application/data/migrations

$ php ./doctrine generate-migrations-db
generate-migrations-db - Generated migration classes successfully from database

$ ls ../application/data/migrations
1274778030_addbal_file.php 1274778038_addbal_roleanduser.php 1274778046_addburn_fileandproject.php 1274778054_addinvoicedatabackup.php 1274778062_addburnprojectindex.php
1274778031_addbal_invoice.php 1274778039_addbal_user.php 1274778047_addburn_imageandproject.php 1274778055_addusergroup.php 1274778063_addideaindex.php
1274778032_addbal_invoiceitem.php 1274778040_addbrief.php 1274778048_addburn_project.php 1274778056_addusergroupanduserfor.php 1274778064_addusergroupindex.php
1274778033_addbal_message.php 1274778041_addbriefandfile.php 1274778049_addburn_recommendation.php 1274778057_addbalfileindex.php 1274778065_addfks.php
1274778034_addbal_permission.php 1274778042_addbriefanduserfor.php 1274778050_addburn_state.php 1274778058_addbalusertaggabletag.php
1274778035_addbal_permissionandrole.php 1274778043_addbrieftype.php 1274778051_addburn_suburb.php 1274778059_addtaggabletag.php
1274778036_addbal_permissionanduser.php 1274778044_addburn_company.php 1274778052_addidea.php 1274778060_addbriefindex.php
1274778037_addbal_role.php 1274778045_addburn_department.php 1274778053_addideaandimage.php 1274778061_addburncompanyindex.php

$ ... make a change to the schema.yml file in my text editor and save, in this case change a column length from 250 to 200 ...

$ php ./doctrine generate-migrations-diff
generate-migrations-diff - Generated migration classes successfully from difference

$ ls ../application/data/migrations
1274778030_addbal_file.php 1274778038_addbal_roleanduser.php 1274778046_addburn_fileandproject.php 1274778054_addinvoicedatabackup.php 1274778062_addburnprojectindex.php
1274778031_addbal_invoice.php 1274778039_addbal_user.php 1274778047_addburn_imageandproject.php 1274778055_addusergroup.php 1274778063_addideaindex.php
1274778032_addbal_invoiceitem.php 1274778040_addbrief.php 1274778048_addburn_project.php 1274778056_addusergroupanduserfor.php 1274778064_addusergroupindex.php
1274778033_addbal_message.php 1274778041_addbriefandfile.php 1274778049_addburn_recommendation.php 1274778057_addbalfileindex.php 1274778065_addfks.php
1274778034_addbal_permission.php 1274778042_addbriefanduserfor.php 1274778050_addburn_state.php 1274778058_addbalusertaggabletag.php 1274778089_version37.php
1274778035_addbal_permissionandrole.php 1274778043_addbrieftype.php 1274778051_addburn_suburb.php 1274778059_addtaggabletag.php
1274778036_addbal_permissionanduser.php 1274778044_addburn_company.php 1274778052_addidea.php 1274778060_addbriefindex.php
1274778037_addbal_role.php 1274778045_addburn_department.php 1274778053_addideaandimage.php 1274778061_addburncompanyindex.php

$ cat ../application/data/migrations/1274778089_version37.php
<?php
/**

  • This class has been auto-generated by the Doctrine ORM Framework
    */
    class Version37 extends Doctrine_Migration_Base
    {
    public function up() { $this->dropTable('bal__file'); $this->dropTable('bal__invoice'); $this->dropTable('bal__invoice_item'); $this->dropTable('bal__message'); $this->dropTable('bal__permission'); $this->dropTable('bal__permission_and_role'); $this->dropTable('bal__permission_and_user'); $this->dropTable('bal__role'); $this->dropTable('bal__role_and_user'); $this->dropTable('bal__user'); $this->dropTable('brief'); $this->dropTable('brief_and_file'); $this->dropTable('brief_and_user_for'); $this->dropTable('brief_type'); $this->dropTable('burn__company'); $this->dropTable('burn__department'); $this->dropTable('burn__file_and_project'); $this->dropTable('burn__image_and_project'); $this->dropTable('burn__project'); $this->dropTable('burn__recommendation'); $this->dropTable('burn__state'); $this->dropTable('burn__suburb'); $this->dropTable('idea'); $this->dropTable('idea_and_image'); $this->dropTable('invoice_data_backup'); $this->dropTable('user_group'); $this->dropTable('user_group_and_user_for'); $this->dropTable('bal_file_index'); $this->dropTable('bal_user_taggable_tag'); $this->dropTable('taggable_tag'); $this->dropTable('brief_index'); $this->dropTable('burn_company_index'); $this->dropTable('burn_project_index'); $this->dropTable('burn_user_taggable_tag'); $this->dropTable('burn_user_index'); $this->dropTable('buyer_taggable_tag'); $this->dropTable('buyer_index'); $this->dropTable('company_index'); $this->dropTable('file_index'); $this->dropTable('idea_index'); $this->dropTable('project_index'); $this->dropTable('seller_taggable_tag'); $this->dropTable('seller_index'); $this->dropTable('user_taggable_tag'); $this->dropTable('user_index'); $this->dropTable('user_group_index'); }

public function down()
{
$this->createTable('bal__file', array(
'id' =>
array(
....



 Comments   
Comment by Benjamin Arthur Lupton [ 25/May/10 ]

Clarity over tables and database.

Comment by Benjamin Arthur Lupton [ 25/May/10 ]

forgot to add the part about me changing the yaml file inbetween

Comment by Jonathan H. Wage [ 08/Jun/10 ]

Hi, I cannot reproduce the issue unfortunately

Comment by SkaveRat [ 26/Nov/10 ]

I have the exact same problem.

Looking at the paths, is seems OP uses the same ZendCasts.com setup for ZendFramework/Doctrine. I think the problem lies somewhere in there. Anyone got an idea?

Comment by SkaveRat [ 26/Nov/10 ]

Okay, found the problem, And I really hope there will be a fix soon, because it one of the biggest features of doctrine:

To get autoloading in ZendFramework correct, Doctrine has to prefix all models with "Model_" (see http://www.zendcasts.com/deep-integration-between-zend-and-doctrine-1-2/2010/01/ for more information)
The problem is, that the Diff-generating script searches for i.e. the class "User" instead of "Model_User", thinks that it doesnt exist, and wants to recreate it from scratch

Comment by Thomas Ingham [ 07/May/12 ]

We're having this same issue in 1.2.3 right now. Has anyone found a workaround? It seems likely that given the age of the last comment - I'm out of luck but yolo.

Generated at Sat Aug 23 01:39:49 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.