views:

1246

answers:

3

how to resolve this symfony error :

C:\inetpub\wwwroot\project\trunk\preprod\signup>php symfony doctrine:build-schema --trace
>> doctrine  generating yaml schema from database


  [sfException]
  Unknown relation alias table_name


Exception trace:
  at C:\inetpub\wwwroot\project\trunk\preprod\signup\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\cli\sfDoctrineCli.class.php:69
 sfDoctrineCli->notifyException at C:\inetpub\wwwroot\ project\trunk\preprod\signup\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\ven
dor\doctrine\Doctrine\Cli.php:93
 Doctrine_Cli->run at C:\inetpub\wwwroot\project\trunk\preprod\signup\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\task\sfDoctrineB
aseTask.class.php:112
 sfDoctrineBaseTask->callDoctrineCli at C:\inetpub\wwwroot\project\trunk\preprod\signup\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\li
b\task\sfDoctrineBuildSchemaTask.class.php:57
 sfDoctrineBuildSchemaTask->execute at C:\inetpub\wwwroot\project\trunk\preprod\signup\lib\vendor\symfony\lib\task\sfBaseTask.class.php:63

 sfBaseTask->doRun at C:\inetpub\wwwroot\project\trunk\preprod\signup\lib\vendor\symfony\lib\task\sfTask.class.php:77
 sfTask->runFromCLI at C:\inetpub\wwwroot\ project\trunk\preprod\signup\lib\vendor\symfony\lib\command\sfSymfonyCommandApplication.class.ph
p:76
 sfSymfonyCommandApplication->run at C:\inetpub\wwwroot\project\trunk\preprod\signup\lib\vendor\symfony\lib\command\cli.php:20
 include at C:\inetpub\wwwroot\project\trunk\preprod\signup\symfony:14
A: 

One of your tables appears to be referencing another table called 'table_name' (unless there's something horribly wrong with Doctrine's error output substitution). Check the relations on all of your tables to find the culprit causing this and remove the relation if it's not valid (do you actually have a table called 'table_name'?) to fix this issue.

If you have a lot of tables you can try replicating your entire database into a temporary test DB and then drop half of the tables and run the generate command again. If you don't get the error you know that chunk of tables is not the problem so drop the existing tables and restore the other half. If the same error still occurs the culprit is now within the current chunk. Continue dropping halves until you're left with just one table erroring out and you'll have found your error source.

If you're still having problems locating the exact cause of the problem can you provide your problem table's structure in SQL and also what version of Doctrine you're working with.

Cryo
+1  A: 

It is a model and cache issue (reset all configuration and erase model and data files)

rm config/doctrine/schema.yml
rm -r cache/*
rm -r data/*
rm -r lib/model/doctrine/base

symfony cc

I found a second response, using builder.php patch to have doctrine object getters in symfony 1.2 cast this error also.

belaz
+1  A: 

those working with Symfony 1.4 will be happy to know that there's a task to clean outdated doctrine models. "./symfony doctrine:clean" will get rid of those nasty "that model don't exist anymore issues".

koss