DDC-1657: The Doctrine cli tool does not handle schema correctly. #2081

Closed
opened 2026-01-22 13:40:02 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 19, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user presteus:

At first time, sorry for my english and I will be short and brief, the problem is clearly explained in the title and the test is very simple.

The entity

/****
 * Short description.
 *
 * @Entity(repositoryClass="Stonewood\Model\Entity\Repository\Screen")
 * @Table(name="stonewood.screen")
 */
class Screen extends Entity
{

    /****
     * Identifier
     * @var integer
     *
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     * @Column(name="pk", type="integer", nullable=false)
     */
    private $pk;

    /****
     * Title
     * @var string
     *
     * @Column(name="title", type="string", length=255, nullable=false)
     */
    private $title;

    /****
     * Path
     * @var string
     *
     * @Column(name="path", type="string", length=255, nullable=false)
     */
    private $path;

    /****
     * Register date
     * @var Date
     *
     * @Column(name="ddate", type="date", nullable=false)
     */
    private $ddate;

    /****
     * Avatar
     * @var Stonewood\Model\Entity\Avatar
     *
     * @ManyToOne(targetEntity="Stonewood\Model\Entity\Avatar")
     * @JoinColumn(name="pk_avatar", referencedColumnName="pk", nullable=true, onDelete="CASCADE")
     */
    private $avatar;

    /****
     *
     */
    public function **construct($pk = null, $title = null, $path = null, $ddate = null, $avatar = null) {
        $this->setPk($pk);
        $this->setTitle($title);
        $this->setPath($path);
        $this->setDdate($ddate);
        $this->setAvatar($avatar);
    }

    [...]

}

Before the first deployment

./doctrine orm:schema-tool:update --dump-sql
CREATE TABLE stonewood.screen (pk SERIAL NOT NULL, pk_avatar INT DEFAULT NULL, title VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, ddate DATE NOT NULL, PRIMARY KEY(pk));
CREATE INDEX IDX*D91A7FB3E9032144 ON stonewood.screen (pk*avatar);

During the first deployement

./doctrine orm:schema-tool:update --force
Updating database schema...
Database schema updated successfully! "100" queries were executed

I test the application and all work correctly

After this test

./doctrine orm:schema-tool:update --dump-sql
ALTER TABLE screen ADD pk SERIAL NOT NULL;
ALTER TABLE screen ADD pk_avatar INT DEFAULT NULL;
ALTER TABLE screen ADD title VARCHAR(255) NOT NULL;
ALTER TABLE screen ADD path VARCHAR(255) NOT NULL;
ALTER TABLE screen ADD ddate DATE NOT NULL;
ALTER TABLE screen ADD CONSTRAINT FK*D91A7FB3E9032144 FOREIGN KEY (pk*avatar) REFERENCES stonewood.avatar (pk) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
CREATE INDEX IDX*D91A7FB3E9032144 ON screen (pk*avatar);
ALTER TABLE screen ADD PRIMARY KEY (pk);

The result is false. I should see Nothing to update - your database is already in sync with the current entity metadata.
In addition, the schema name does not appear, except for foreign key, what must be causing the problem.

Originally created by @doctrinebot on GitHub (Feb 19, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user presteus: At first time, sorry for my english and I will be short and brief, the problem is clearly explained in the title and the test is very simple. **The entity** ``` /**** * Short description. * * @Entity(repositoryClass="Stonewood\Model\Entity\Repository\Screen") * @Table(name="stonewood.screen") */ class Screen extends Entity { /**** * Identifier * @var integer * * @Id * @GeneratedValue(strategy="IDENTITY") * @Column(name="pk", type="integer", nullable=false) */ private $pk; /**** * Title * @var string * * @Column(name="title", type="string", length=255, nullable=false) */ private $title; /**** * Path * @var string * * @Column(name="path", type="string", length=255, nullable=false) */ private $path; /**** * Register date * @var Date * * @Column(name="ddate", type="date", nullable=false) */ private $ddate; /**** * Avatar * @var Stonewood\Model\Entity\Avatar * * @ManyToOne(targetEntity="Stonewood\Model\Entity\Avatar") * @JoinColumn(name="pk_avatar", referencedColumnName="pk", nullable=true, onDelete="CASCADE") */ private $avatar; /**** * */ public function **construct($pk = null, $title = null, $path = null, $ddate = null, $avatar = null) { $this->setPk($pk); $this->setTitle($title); $this->setPath($path); $this->setDdate($ddate); $this->setAvatar($avatar); } [...] } ``` Before the first deployment ``` ./doctrine orm:schema-tool:update --dump-sql CREATE TABLE stonewood.screen (pk SERIAL NOT NULL, pk_avatar INT DEFAULT NULL, title VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, ddate DATE NOT NULL, PRIMARY KEY(pk)); CREATE INDEX IDX*D91A7FB3E9032144 ON stonewood.screen (pk*avatar); ``` During the first deployement ``` ./doctrine orm:schema-tool:update --force Updating database schema... Database schema updated successfully! "100" queries were executed ``` **I test the application and all work correctly** After this test ``` ./doctrine orm:schema-tool:update --dump-sql ALTER TABLE screen ADD pk SERIAL NOT NULL; ALTER TABLE screen ADD pk_avatar INT DEFAULT NULL; ALTER TABLE screen ADD title VARCHAR(255) NOT NULL; ALTER TABLE screen ADD path VARCHAR(255) NOT NULL; ALTER TABLE screen ADD ddate DATE NOT NULL; ALTER TABLE screen ADD CONSTRAINT FK*D91A7FB3E9032144 FOREIGN KEY (pk*avatar) REFERENCES stonewood.avatar (pk) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE; CREATE INDEX IDX*D91A7FB3E9032144 ON screen (pk*avatar); ALTER TABLE screen ADD PRIMARY KEY (pk); ``` The result is false. I should see _Nothing to update - your database is already in sync with the current entity metadata._ In addition, the schema name does not appear, except for foreign key, what must be causing the problem.
admin added the Bug label 2026-01-22 13:40:02 +01:00
admin closed this issue 2026-01-22 13:40:03 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 19, 2012):

@doctrinebot commented on GitHub (Feb 19, 2012): - is referenced by [DBAL-1096: schema-tool:update does not understand columnDefinition correctly](http://www.doctrine-project.org/jira/browse/DBAL-1096)
Author
Owner

@doctrinebot commented on GitHub (May 27, 2012):

Comment created by @beberlei:

This issue was partially fixed in DBAL already, however it seems there is still a problem with sequence detection.

@doctrinebot commented on GitHub (May 27, 2012): Comment created by @beberlei: This issue was partially fixed in DBAL already, however it seems there is still a problem with sequence detection.
Author
Owner

@doctrinebot commented on GitHub (Jul 8, 2012):

Comment created by @beberlei:

Fixed the sequence problem in 2.3, the other schema problems where indeed fixed in 2.2.1 already.

@doctrinebot commented on GitHub (Jul 8, 2012): Comment created by @beberlei: Fixed the sequence problem in 2.3, the other schema problems where indeed fixed in 2.2.1 already.
Author
Owner

@doctrinebot commented on GitHub (Jul 8, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jul 8, 2012): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2081