I'm following the test setup described here and also here. When I attempt to run my tests, and the test db is in the process of being created, I get the following errors:
[Doctrine\ORM\Tools\ToolsException]
Schema-Tool failed with Error 'An exception occurred while executing 'CREATE INDEX deletedAtidx ON SurveyHash (deletedAt)':
SQLSTATE[HY000]: General error: 1 index deletedAtidx already exists' while executing DDL: CREATE INDEX deletedAtidx ON SurveyHash (deletedAt)[Doctrine\DBAL\Exception\TableExistsException]
An exception occurred while executing 'CREATE INDEX deletedAtidx ON SurveyHash (deletedAt)':
SQLSTATE[HY000]: General error: 1 index deletedAtidx already exists[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000]: General error: 1 index deletedAtidx already exists[PDOException]
SQLSTATE[HY000]: General error: 1 index deletedAtidx already existsdoctrine:schema:create [--dump-sql] [--em[="..."]]
purging database
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'DELETE FROM PageImage':
SQLSTATE[HY000]: General error: 1 no such table: PageImage[PDOException]
SQLSTATE[HY000]: General error: 1 no such table: PageImagedoctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]
Doctrine\DBAL\Exception\TableNotFoundException : An exception occurred while executing 'SELECT t0.label AS label_1, t0.value AS value_2 FROM Setting t0 WHERE t0.label = ? LIMIT 1' with params ["webservice"]:
SQLSTATE[HY000]: General error: 1 no such table: Setting
Looking at my entities, the deletedAt
index is not declared twice in my SurveyHash
entity, and I have entities for both PageImage
and Setting
, yet those tables aren't being created, as verified by sqliteman. Futher testing (see the comments in one of the answers below) show that it's throwing an error due to multiple tables using the same index name.
My config_test.yml
has the following:
doctrine:
dbal:
driver: pdo_sqlite
path: %kernel.cache_dir%/test.db
charset: UTF8
orm:
auto_generate_proxy_classes: true
auto_mapping: true
I'm a bit limited in the database info I can share due to a NDA, so I'm hoping these errors are a result of something in the links above or my config_test.yml
. I'm using Symfony 2.4.6, if that makes a difference.
It seams you have maybe duplicated your deletedAtidx. Search in your mapping config for it. If not, try to recreate the database (if you have no important data)
You should make work the command
doctrine:schema:create
beforedoctrine:fixtures:load
Try
doctrine:schema:update --force
I think that you're trying to do a
doctrine:schema:update
on tables where the datasets have foreign keys or you're trying to add multiple datasets.What you could try is so to drop the database schema, recreate it and then refill it with the data.
So first do a
php app/console doctrine:schema:drop --force
, thenphp app/console doctrine:schema:create
and thendoctrine:fixtures:load
.I had the same issues and this works for me.
I just flown over the first link and what you're doing is to call
doctrine:schema:create
multiple times, which of course won't work because you've already created them. You only coulddoctrine:schema:update --force
them or recreate with drop/create!ANSWER
According to the comments below this Answer the Error was that he gave differnet indexes on different tables the same name, but the
names from index MUST be unique!