开发者

Symfony Doctrine migrations : removeIndex not working

开发者 https://www.devze.com 2023-01-14 03:17 出处:网络
I\'m using Symfony 1.4 with Doctrine. Here\'s my initial schema: Page: tableName: page columns: ref: type: string(50)

I'm using Symfony 1.4 with Doctrine.

Here's my initial schema:

Page:
  tableName: page
  columns:
    ref:
      type: string(50)
      notnull: true
      unique: true

I'd like to remove the index on the ref column using migrations. So the schema becomes:

Page:
  tableName: page
  columns:
    ref:
      type: string(50)
      notnull: true

And my migration file is开发者_JAVA百科 something like:

class Changepageref extends Doctrine_Migration_Base
{
  public function up()
  { 
    $this->removeIndex('page','ref');
  }

  public function down()
  {
    $this->addIndex('page','ref', array('fields'=>array('ref'=>array()),'unique'=>true));
  }
}

But this won't work when I run it because it's looking for an index named "ref_idx". But if I look at my database, doctrine created an index named "ref", not "ref_idx".

What am I doing wrong?


You can define the default naming of the indexes: the default is "_idx". You can change in on the connection manager.

http://www.doctrine-project.org/projects/orm/1.2/docs/manual/configuration/en#naming-convention-attributes shows it like

$manager->setAttribute(Doctrine_Core::ATTR_IDXNAME_FORMAT, '%s_index');

Try to set it there and it should be persistent throughout your application with the index names.

0

精彩评论

暂无评论...
验证码 换一张
取 消