DDC-625: orm:schema-tool:update --dump-sql showing SQL when DB is up-to-date #5134

Closed
doctrinebot opened this Issue Jun 3, 2010 · 5 comments

2 participants

@doctrinebot

Jira issue originally created by user darkangel:

With the following entities ...\
\


/****
 * @Entity
 * @Table(name="users")
 */
class App*Model*User
{
    /****
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     * @Column(type="integer")
     */
    private $id;

    /****
     * @ManyToOne(targetEntity="App*Model*Role")
     * @JoinColumn(name="role_id", nullable=false)
     */
    private $role;

    /*** @Column(type="string", columnDefinition="CHAR(64) NOT NULL") **/
    private $password;
}

<?php

/****
 * @Entity
 * @Table(name="roles")
 */
class App*Model*Role
{
    /****
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     * @Column(type="smallint")
     */
    private $id;
}```

I'm getting this output from orm:schema-tool:update --dump-sql, when the database is already up-to-date:

```ALTER TABLE users CHANGE password password CHAR(64) NOT NULL;
ALTER TABLE users DROP FOREIGN KEY users*ibfk*1;
ALTER TABLE users ADD FOREIGN KEY (role_id) REFERENCES roles(id)```
@doctrinebot

Comment created by shurakai:

This is most probably equivalent with the following problem:

{quote}
It's got to do with cli: when you DB is up to date and you run orm:schema-tool:update --dump-sql, you get something like this:

ALTER TABLE user_users CHANGE avatar avatar LONGTEXT NOT NULL <- but the column avatar is already LONGTEXT

This is caused by the following: Two schema objects are being compared. The first schema is created from the current mapping files (YAML, e.g.) and within these, this column is marked as "object". When the DB is setup, object is transferred into another type, like LONGTEXT. (Platform dependent)

The second schema is created from your current database and is marked as "TextType" because Doctrine cannot decide which other type - there are several who use LONGTEXT - would be correct
{quote}

See /DBAL/Schema/Comparator.php ll. 172ff. & 293

Comparing whether both Types return the same SQL-Statement might do the job but would be really ugly.

@doctrinebot

Comment created by @beberlei:

The columnDefintion affected field can obviously not be solved by any means.

The foreign key thing i see more often in my own projects though, i have to dig deeper there.

@doctrinebot

Comment created by @beberlei:

Fixed Foreign Key issue in DBAL master, it was an error in the MySQL query to fetch the foreign keys.

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.0-BETA3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment