mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1118: doctrine:schema:update fails #1399
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Apr 16, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user xaav:
First, I'll give you the code upfront so you don't have to waste time asking:
[code]$ php app/console doctrine:schema:update --force
Updating database schema...
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your S
QL syntax; check the manual that corresponds to your MySQL server version for the rig
ht syntax to use near 'Index (id INT AUTO_INCREMENT NOT NULL, profile_id INT DEFAULT
NULL, url VARCHAR(' at line 1
doctrine:schema:update [--complete] [--dump-sql] [--force] [--em[="..."]]
$ php app/console doctrine:schema:update --dump-sql
CREATE TABLE Index (id INT AUTO_INCREMENT NOT NULL, profile_id INT DEFAULT NULL, url
VARCHAR(255) NOT NULL, text LONGTEXT NOT NULL, INDEX IDX_41B24805CCFA12B8 (profile_id
), PRIMARY KEY(id)) ENGINE = InnoDB;
CREATE TABLE Profile (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, url
VARCHAR(255) NOT NULL, regex VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB
;
ALTER TABLE Index ADD FOREIGN KEY (profile_id) REFERENCES Profile(id)
[/code]
[code]<?php
namespace TSEP\SearchBundle\Entity;
/****
@orm:Entity
/
class Profile
{
/***
*/
protected $id;
/****
*/
protected $name;
/****
*/
protected $url;
/****
*/
protected $regex;
/****
*@orm:OneToMany(targetEntity="Index", mappedBy="Profile")
*/
protected $indices;
}[/code]
[code]<?php
namespace TSEP\SearchBundle\Entity;
/****
@orm:Entity
/
class Index
{
/***
*/
protected $id;
/****
*/
protected $url;
/****
*/
protected $text;
/****
*@orm:ManyToOne(targetEntity="Profile", inversedBy="Index")
*/
protected $profile;
}[/code]
[code]# Doctrine Configuration
doctrine:
dbal:
default_connection: default
connections:
default:
driver: %database_driver%
host: %database_host%
dbname: %database_name%
user: %database_user%
password: %database_password%
[/code]
Please let me know if you need any more information.
@doctrinebot commented on GitHub (Apr 16, 2011):
Comment created by xaav:
Since your bug tracker seems to have un-formatted the source, you can look here:
http://forum.symfony-project.org/viewtopic.php?f=23&t=34597
To see the source formatted correctly.
@doctrinebot commented on GitHub (Apr 17, 2011):
Comment created by @beberlei:
This is not an issue, Index is a reserved keyword in SQL and this is not escaped by Doctrine for various reasons.
You have to rename the table (best solution) or escape it explicitly as shown in the docs (fast solution).
@doctrinebot commented on GitHub (Apr 17, 2011):
Issue was closed with resolution "Invalid"