douzhan6474 2014-06-10 18:41
浏览 67
已采纳

doctrine:schema:update不遵守列顺序

I have this Entity in Symfony2 :

<?php

namespace Project\UserBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Users
 *
 * @ORM\Table(name="users")
 * @ORM\Entity
 */
class Users
{
    /**
     * @var integer
     *
     * @ORM\Column(name="user_id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $userId;


    /**
     * @var integer
     *
     * @ORM\Column(name="test", type="integer", nullable=false)
     */
    private $test;
}

I add the following line between {{userId}} and {{test}} :

/**
 * @var integer
 *
 * @ORM\Column(name="superbanana", type="integer", nullable=false)
 */
private $superbanana;

Then I execute in console :

php app/console doctrine:schema:update --dump-sql

It give me the response :

ALTER TABLE users ADD superbanana INT NOT NULL

**How can I do to have instead ? **

ALTER TABLE users ADD superbanana INT NOT NULL AFTER user_id
  • 写回答

2条回答 默认 最新

  • dryift6733 2014-06-11 05:54
    关注

    If you don't want to drop/create the table, you can use @columnDefinition attribute and define the column definition yourself.

    /**
     * @var integer
     *
     * @ORM\Column(type="integer", columnDefinition="INT NOT NULL AFTER `user_id`")
     */
    private $superbanana;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀