doctrine / DoctrineBundle

Symfony Bundle for Doctrine ORM and DBAL
https://www.doctrine-project.org/projects/doctrine-bundle.html
MIT License
4.72k stars 454 forks source link

':validate' after successful ':update --force' FAILs: "schema is not in sync with the current mapping file" #765

Closed ghost closed 6 years ago

ghost commented 6 years ago

with

composer show | egrep -i "symfony/frame|doctrine/.*bundle"
    doctrine/doctrine-bundle                 1.8.1              Symfony DoctrineBundle
    doctrine/doctrine-cache-bundle           1.3.2              Symfony Bundle for Doctrin...
    doctrine/doctrine-fixtures-bundle        3.0.2              Symfony DoctrineFixturesBu...
    doctrine/doctrine-migrations-bundle      v1.3.1             Symfony DoctrineMigrations...
    doctrine/phpcr-bundle                    dev-master 5362438 Symfony DoctrinePHPCRBundle
    symfony/framework-bundle                 v4.0.3             Symfony FrameworkBundle

for a schema update

bin/console doctrine:schema:update --dump-sql

     The following SQL statements will be executed:

         ALTER TABLE fos_user CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE last_login last_login DATETIME DEFAULT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL, CHANGE password_requested_at password_requested_at DATETIME DEFAULT NULL;
         ALTER TABLE fos_user_user CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE last_login last_login DATETIME DEFAULT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL, CHANGE password_requested_at password_requested_at DATETIME DEFAULT NULL, CHANGE date_of_birth date_of_birth DATETIME DEFAULT NULL, CHANGE firstname firstname VARCHAR(64) DEFAULT NULL, CHANGE lastname lastname VARCHAR(64) DEFAULT NULL, CHANGE website website VARCHAR(64) DEFAULT NULL, CHANGE biography biography VARCHAR(1000) DEFAULT NULL, CHANGE gender gender VARCHAR(1) DEFAULT NULL, CHANGE locale locale VARCHAR(8) DEFAULT NULL, CHANGE timezone timezone VARCHAR(64) DEFAULT NULL, CHANGE phone phone VARCHAR(64) DEFAULT NULL, CHANGE facebook_uid facebook_uid VARCHAR(255) DEFAULT NULL, CHANGE facebook_name facebook_name VARCHAR(255) DEFAULT NULL, CHANGE facebook_data facebook_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE twitter_uid twitter_uid VARCHAR(255) DEFAULT NULL, CHANGE twitter_name twitter_name VARCHAR(255) DEFAULT NULL, CHANGE twitter_data twitter_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE gplus_uid gplus_uid VARCHAR(255) DEFAULT NULL, CHANGE gplus_name gplus_name VARCHAR(255) DEFAULT NULL, CHANGE gplus_data gplus_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE token token VARCHAR(255) DEFAULT NULL, CHANGE two_step_code two_step_code VARCHAR(255) DEFAULT NULL;
         ALTER TABLE acl_object_identities CHANGE parent_object_identity_id parent_object_identity_id INT UNSIGNED DEFAULT NULL;
         ALTER TABLE acl_entries CHANGE object_identity_id object_identity_id INT UNSIGNED DEFAULT NULL, CHANGE field_name field_name VARCHAR(50) DEFAULT NULL;

bin/console doctrine:schema:update --force
     Updating database schema...
         4 queries were executed
     [OK] Database schema updated successfully!

immediately subsequent validation fails

bin/console doctrine:schema:validate -vvv
    Mapping
    -------
     [OK] The mapping files are correct.

    Database
    --------
     [ERROR] The database schema is not in sync with the current mapping file.

iiuc, the ":update --force" is the method to sync

Ocramius commented 6 years ago

What are the ORM/DBAL versions? Also, does that still happen when you remove the "unsigned" definition from the mappings?

On 24 Jan 2018 21:05, "pgnd" notifications@github.com wrote:

with

composer show | egrep -i "symfony/frame|doctrine/.*bundle" doctrine/doctrine-bundle 1.8.1 Symfony DoctrineBundle doctrine/doctrine-cache-bundle 1.3.2 Symfony Bundle for Doctrin... doctrine/doctrine-fixtures-bundle 3.0.2 Symfony DoctrineFixturesBu... doctrine/doctrine-migrations-bundle v1.3.1 Symfony DoctrineMigrations... doctrine/phpcr-bundle dev-master 5362438 Symfony DoctrinePHPCRBundle symfony/framework-bundle v4.0.3 Symfony FrameworkBundle

for a schema update

bin/console doctrine:schema:update --dump-sql

 The following SQL statements will be executed:

     ALTER TABLE fos_user CHANGE salt salt VARCHAR(255) DEFAULT NULL,

CHANGE last_login last_login DATETIME DEFAULT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL, CHANGE password_requested_at password_requested_at DATETIME DEFAULT NULL; ALTER TABLE fos_user_user CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE last_login last_login DATETIME DEFAULT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL, CHANGE password_requested_at password_requested_at DATETIME DEFAULT NULL, CHANGE date_of_birth date_of_birth DATETIME DEFAULT NULL, CHANGE firstname firstname VARCHAR(64) DEFAULT NULL, CHANGE lastname lastname VARCHAR(64) DEFAULT NULL, CHANGE website website VARCHAR(64) DEFAULT NULL, CHANGE biography biography VARCHAR(1000) DEFAULT NULL, CHANGE gender gender VARCHAR(1) DEFAULT NULL, CHANGE locale locale VARCHAR(8) DEFAULT NULL, CHANGE timezone timezone VARCHAR(64) DEFAULT NULL, CHANGE phone phone VARCHAR(64) DEFAULT NULL, CHANGE facebook_uid facebook_uid VARCHAR(255) DEFAULT NULL, CHANGE facebook_name facebook_name VARCHAR(255) DEFAULT NULL, CHANGE facebook_data facebook_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE twitter_uid twitter_uid VARCHAR(255) DEFAULT NULL, CHANGE twitter_name twitter_name VARCHAR(255) DEFAULT NULL, CHANGE twitter_data twitter_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE gplus_uid gplus_uid VARCHAR(255) DEFAULT NULL, CHANGE gplus_name gplus_name VARCHAR(255) DEFAULT NULL, CHANGE gplus_data gplus_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE token token VARCHAR(255) DEFAULT NULL, CHANGE two_step_code two_step_code VARCHAR(255) DEFAULT NULL; ALTER TABLE acl_object_identities CHANGE parent_object_identity_id parent_object_identity_id INT UNSIGNED DEFAULT NULL; ALTER TABLE acl_entries CHANGE object_identity_id object_identity_id INT UNSIGNED DEFAULT NULL, CHANGE field_name field_name VARCHAR(50) DEFAULT NULL;

bin/console doctrine:schema:update --force Updating database schema... 4 queries were executed [OK] Database schema updated successfully!

immediately subsequent validation fails

bin/console doctrine:schema:validate -vvv Mapping

 [OK] The mapping files are correct.

Database
--------
 [ERROR] The database schema is not in sync with the current mapping file.

iiuc, the ":update --force" is the method to sync

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/doctrine/DoctrineBundle/issues/765, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakFIzrc2fJtU-oH3L77YHo4KXmTLtks5tN4z_gaJpZM4Rr2gB .

ghost commented 6 years ago

What are the ORM/DBAL versions?

composer show | grep doctrine | egrep -i "orm|dbal"
doctrine/dbal                            v2.6.3             Database Abstraction Layer
doctrine/migrations                      v1.6.2             Database Schema migrations using Doctrine DBAL
doctrine/orm                             v2.6.0             Object-Relational-Mapper for PHP
jackalope/jackalope-doctrine-dbal        1.3.1              Jackalope Transport library for Doctrine DBAL
sonata-project/doctrine-orm-admin-bundle 3.4.1              Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle

Also, does that still happen when you remove the "unsigned" definition from the mappings?

Not clear what you mean by 'unsigned definition' -- Disabling the 'easy-extended', Sonata User Bundle ?

That

    orm:
        ...
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App
            FOSUserBundle: ~
            SonataUserBundle: ~
-           ApplicationSonataUserBundle: ~
+           #ApplicationSonataUserBundle: ~

has no effect; same error.

Ocramius commented 6 years ago

Disabling the 'easy-extended', Sonata User Bundle ?

I have no idea what that is :-)

ALTER TABLE fos_user CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE last_login last_login DATETIME DEFAULT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL, CHANGE password_requested_at password_requested_at DATETIME DEFAULT NULL;

This seems to be adding nullability to all your fields. Maybe this is related to https://github.com/doctrine/dbal/pull/2825 ?

stof commented 6 years ago

@pgnd what does schema:update --dump-sql dispay after the second validate failure ? I would like to know which kind of changes are still expected to be done by the second validation.

ghost commented 6 years ago

@ocramius

I have no idea what that is :-)

it is disabling the orm mapping definition for the bundle

-           ApplicationSonataUserBundle: ~
+           #ApplicationSonataUserBundle: ~

that's created by exec'ing easy-extend for the SonataUserBundle

bin/console -vvv sonata:easy-extends:generate \
 --dest="src" \
 --namespace_prefix="App" \
SonataUserBundle

I see that's 'locked as resolved' and merged into master 20 days ago.

I've latest release tag

doctrine/dbal   v2.6.3    Database Abstraction Layer

from Nov '17. Guess it's not in release, then; I'll take a read through.

@stof

what does schema:update --dump-sql dispay


bin/console cache:clear
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.

bin/console doctrine:schema:update --force Updating database schema... 4 queries were executed [OK] Database schema updated successfully!

bin/console doctrine:schema:validate Mapping

 [OK] The mapping files are correct.

Database
--------
 [ERROR] The database schema is not in sync with the current mapping file.

bin/console doctrine:schema:update --dump-sql The following SQL statements will be executed:

     ALTER TABLE fos_user CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE last_login last_login DATETIME DEFAULT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL, CHANGE password_requested_at password_requested_at DATETIME DEFAULT NULL;
     ALTER TABLE fos_user_user CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE last_login last_login DATETIME DEFAULT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL, CHANGE password_requested_at password_requested_at DATETIME DEFAULT NULL, CHANGE date_of_birth date_of_birth DATETIME DEFAULT NULL, CHANGE firstname firstname VARCHAR(64) DEFAULT NULL, CHANGE lastname lastname VARCHAR(64) DEFAULT NULL, CHANGE website website VARCHAR(64) DEFAULT NULL, CHANGE biography biography VARCHAR(1000) DEFAULT NULL, CHANGE gender gender VARCHAR(1) DEFAULT NULL, CHANGE locale locale VARCHAR(8) DEFAULT NULL, CHANGE timezone timezone VARCHAR(64) DEFAULT NULL, CHANGE phone phone VARCHAR(64) DEFAULT NULL, CHANGE facebook_uid facebook_uid VARCHAR(255) DEFAULT NULL, CHANGE facebook_name facebook_name VARCHAR(255) DEFAULT NULL, CHANGE facebook_data facebook_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE twitter_uid twitter_uid VARCHAR(255) DEFAULT NULL, CHANGE twitter_name twitter_name VARCHAR(255) DEFAULT NULL, CHANGE twitter_data twitter_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE gplus_uid gplus_uid VARCHAR(255) DEFAULT NULL, CHANGE gplus_name gplus_name VARCHAR(255) DEFAULT NULL, CHANGE gplus_data gplus_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', CHANGE token token VARCHAR(255) DEFAULT NULL, CHANGE two_step_code two_step_code VARCHAR(255) DEFAULT NULL;
     ALTER TABLE acl_object_identities CHANGE parent_object_identity_id parent_object_identity_id INT UNSIGNED DEFAULT NULL;
     ALTER TABLE acl_entries CHANGE object_identity_id object_identity_id INT UNSIGNED DEFAULT NULL, CHANGE field_name field_name VARCHAR(50) DEFAULT NULL;
ghost commented 6 years ago

from Nov '17. Guess it's not in release, then; I'll take a read through.

updating doctrine/dbal to master

composer require doctrine/dbal:dev-master
    doctrine/dbal     dev-master 1faeb78 Database Abstraction Layer

bin/console cache:clear
bin/console doctrine:schema:update --force
bin/console doctrine:schema:validate

still returns same error & dump-sql ...

ghost commented 6 years ago

@stof

Seeing similar after migrations:diff + migrations:migrate:

https://pastebin.com/p8CDS44k

quisse commented 5 years ago

Why is this closed? I also have this issue. Edit: nevermind, it was something else. But some clarification why this one is closed could be helpfull for others like me who get here via google.

stof commented 4 years ago

@alexxk82 please create a new ticket with details about your own issue, instead of commenting with Same issue here on a ticket that was closed more than 2 years ago by the reporter themselves (and so for which the reporter might have found a solution without posting it back).