Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBALException when updating schema #96

Open
jstoeffler opened this issue Jan 14, 2016 · 5 comments
Open

DBALException when updating schema #96

jstoeffler opened this issue Jan 14, 2016 · 5 comments

Comments

@jstoeffler
Copy link

Using Symfony 2.6 with this wonderful bundle, I tried to update the database, and I get the following error:

[Doctrine\DBAL\DBALException]                                                                                                                                                                            
An exception occurred while executing 'ALTER TABLE wp_term_taxonomy ADD CONSTRAINT FK_C4D725F53D8E604F FOREIGN KEY (parent) REFERENCES wp_terms (term_id)':                                              
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`crp-img`.`#sql-31c0_167`, CONSTRAINT `FK_C4D725F53D8E604F` FOREIGN KEY (`parent`) REFERENCES `wp_terms` (`term_id`))                      

It seems that Doctrine tries to override the Wordpress constraint, or am I missing something? It did perform a lot of updates on the Wordpress tables with tables when I first ran the update.

It also tries to update those:

ALTER TABLE wp_links CHANGE link_notes link_notes MEDIUMTEXT NOT NULL;
ALTER TABLE wp_term_taxonomy ADD CONSTRAINT FK_C4D725F53D8E604F FOREIGN KEY (parent) REFERENCES wp_terms (term_id);
CREATE INDEX IDX_C4D725F53D8E604F ON wp_term_taxonomy (parent);
ALTER TABLE wp_users CHANGE user_pass user_pass VARCHAR(64) DEFAULT '' NOT NULL, CHANGE user_registered user_registered DATETIME DEFAULT '1970-01-01 00:00:00' NOT NULL, CHANGE user_activation_key user_activation_key VARCHAR(60) DEFAULT '' NOT NULL;
ALTER TABLE wp_usermeta CHANGE umeta_id umeta_id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE user_id user_id BIGINT UNSIGNED DEFAULT NULL;
ALTER TABLE wp_usermeta ADD CONSTRAINT FK_F3914E8EA76ED395 FOREIGN KEY (user_id) REFERENCES wp_users (ID);

Is this normal? Is there a proper way to update the schema with this bundle?

@epci
Copy link

epci commented Jan 23, 2016

Same problem

@jstoeffler
Copy link
Author

It seems to work using a different entity manager for the bundle and the app. So your app will ignore the WP entities.

@epci
Copy link

epci commented Feb 29, 2016

hi @jstoeffler

Have you an example of the good configuration to work with different entity manager, i try this, but it don't work

``
doctrine:
dbal:
default_connection: symfony
connections:
symfony:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name_symfony%'
user: '%database_user_symfony%'
password: '%database_password_symfony%'
charset: UTF8
wordpress:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name_wordpress%'
user: '%database_user_wordpress%'
password: '%database_password_wordpress%'
charset: UTF8

orm:
    default_entity_manager: default
    entity_managers:
        symfony:
            connection: symfony
            mappings:
                AppBundle:  ~
        wordpress:
            connection: wordpress
            mappings:
                EkinoWordpressBundle: ~

``

@jstoeffler
Copy link
Author

The problem could come from

default_entity_manager: default

You could replace it by:

default_entity_manager: symfony

or rename the symfony em to "default".

Also I don't use different DB connections, it shouldn't be a problem, but is it necessary?

@steffi2392
Copy link

Hi -- I'm having the same problem. Has anyone found a workaround other than using a different entity manager? When I use a different entity manager, I am unable to use the entities from the ekino bundle as foreign keys in my symfony entity manager. (Or has someone found a way to do that successfully?) Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants