Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法将实体与Symfony中的数据库同步_Symfony - Fatal编程技术网

无法将实体与Symfony中的数据库同步

无法将实体与Symfony中的数据库同步,symfony,Symfony,我开始探索Symfony,然后通过导入脚本创建模式,并按照以下命令创建实体: Importing mapping information by generating the metadata files: $ php app/console doctrine:mapping:import --force AcmeBlogBundle xml Build related entity classes: -> Generates entity classes with an

我开始探索Symfony,然后通过导入脚本创建模式,并按照以下命令创建实体:

Importing mapping information by generating the metadata files:

    $ php app/console doctrine:mapping:import --force AcmeBlogBundle xml

Build related entity classes:
    -> Generates entity classes with annotation mappings
    $ php app/console doctrine:mapping:convert annotation ./src
    $ php app/console doctrine:generate:entities AcmeBlogBundle
命令:

$ php app/console doctrine:schema:update --force
失败,出现以下错误:

[Doctrine\DBAL\Exception\DriverException]                                                                              
  An exception occurred while executing 'ALTER TABLE writtings CHANGE id id INT AUTO_INCREMENT NOT NULL':                
  SQLSTATE[HY000]: General error: 1025 Error on rename of './amimusa/#sql-425_5e' to './amimusa/writtings' (errno: 150)                                                                                                 
  [Doctrine\DBAL\Driver\PDOException]                                                                                    
  SQLSTATE[HY000]: General error: 1025 Error on rename of './amimusa/#sql-425_5e' to './amimusa/writtings' (errno: 150)  
  [PDOException]                                                                                                         
  SQLSTATE[HY000]: General error: 1025 Error on rename of './amimusa/#sql-425_5e' to './amimusa/writtings' (errno: 150)  
生成的转储文件是:

ALTER TABLE writtings CHANGE id id INT AUTO_INCREMENT NOT NULL;
ALTER TABLE writtings ADD CONSTRAINT FK_F9A6AFF48726D6E4 FOREIGN KEY (publication_type) REFERENCES publications_type (id);
ALTER TABLE musas CHANGE id id INT AUTO_INCREMENT NOT NULL;
ALTER TABLE publications DROP FOREIGN KEY contributor_FK;
ALTER TABLE publications DROP FOREIGN KEY state_FK;
ALTER TABLE publications DROP FOREIGN KEY writting_FK;
ALTER TABLE publications CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE id_contributor id_contributor INT DEFAULT NULL, CHANGE id_state id_state INT DEFAULT NULL, CHANGE id_writting id_writting INT DEFAULT NULL;
ALTER TABLE publications ADD CONSTRAINT FK_32783AF440C1075C FOREIGN KEY (id_writting) REFERENCES writtings (id);
ALTER TABLE publications ADD CONSTRAINT FK_32783AF44D1693CB FOREIGN KEY (id_state) REFERENCES states (id);
ALTER TABLE publications ADD CONSTRAINT FK_32783AF4C27D5A64 FOREIGN KEY (id_contributor) REFERENCES contributors (id);
ALTER TABLE publications_musas DROP FOREIGN KEY musa_FK;
ALTER TABLE publications_musas DROP FOREIGN KEY publication_FK;
ALTER TABLE publications_musas DROP FOREIGN KEY musa_FK;
ALTER TABLE publications_musas CHANGE id_publication id_publication INT NOT NULL, CHANGE id_musa id_musa INT NOT NULL;
ALTER TABLE publications_musas ADD CONSTRAINT FK_7EF2161FB72EAA8E FOREIGN KEY (id_publication) REFERENCES publications (id);
ALTER TABLE publications_musas ADD CONSTRAINT FK_7EF2161FFB53D80 FOREIGN KEY (id_musa) REFERENCES musas (id);
DROP INDEX musa_fk ON publications_musas;
CREATE INDEX IDX_7EF2161FFB53D80 ON publications_musas (id_musa);
ALTER TABLE publications_musas ADD CONSTRAINT musa_FK FOREIGN KEY (id_musa) REFERENCES musas (id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE contributors CHANGE id id INT AUTO_INCREMENT NOT NULL;
ALTER TABLE states CHANGE id id INT AUTO_INCREMENT NOT NULL;
谁能帮我理解更新失败的原因? 我也不明白为什么需要这些操作,因为一切都是从头开始创建的。

如评论所述:


逆向工程的东西并不完美。教条喜欢有 事物以自己的方式定义它。我建议删除数据库 使用条令:模式:创建以条令希望的方式重建它 是


已经解决了这个问题。

逆向工程的东西并不完美。教义喜欢用自己的方式来定义事物。我建议先删除数据库,然后使用条令:模式:create以条令所希望的方式重建它。是的,这是有效的!谢谢
$ php app/console doctrine:schema:drop --force
$ php app/console doctrine:schema:create