wohral
wohral

Reputation: 85

How to specify position of new column in Doctrine2 using by annotation and schema-tool

Is there any way, to specify in annotation, where newly added column would be insesrted.

I am using schema-tool from doctrine2 and I am making a update of entity. I want to ask, if is there any way to make something like this:

ALTER TABLE 'mytable' ADD COLUMN 'column2' AFTER 'column1'

I tried something like that, but it doesn't work:

/**
 * @Column(type="string")
 */
protected $column1;

/**
 * @Column(type="string", columnDefinition="AFTER column1")
 */
protected $column2;

Upvotes: 0

Views: 113

Answers (2)

wohral
wohral

Reputation: 85

Thanks, now i tried and it works. But it's quite boring to define always datatype. :(

i can imagine prettier solutin, something like

 /**
 * @Column(name='column2', type="string", option={"after":"password})
 */
 protected $column2;

But it worked, thank you

Upvotes: 0

Dmitry Malyshenko
Dmitry Malyshenko

Reputation: 3051

Did you try

    /**
    * @Column(name="column1", type="string")
    */
    protected $column1;

    /**
     * @Column(name='column2', type="string", columnDefinition="VARCHAR(255) AFTER column1")
     */
    protected $column2;

Upvotes: 1

Related Questions