everyone. Happy new year! Today I am having problems trying to resolving this problem:
Could not resolve type of column “id_usuario” of class “FacturadorVirtualModelosSeguridadUsuario”
For some, this error is only present in linux enviroment. In windows, no problem. What the problem is exactly? Looks like PlanAdquirido
is not finding the column id_usuario
through the relationship $adquiridoPor
. Again: this error is only triggered in linux enviroment.
Usuario entity:
<?php
namespace FacturadorVirtualModelosSeguridad;
use IlluminateContractsAuthAuthenticatable;
/**
* @entity
* @table(name="usuarios")
*/
class Usuario implements Authenticatable
{
/**
* @id
* @var integer
* @column(type="integer", name="id_usuario")
* @generatedValue(strategy="AUTO")
*/
protected $id;
}
PlanAdquirido entity:
<?php
namespace FacturadorVirtualModelosPlanes;
use DoctrineCommonCollectionsArrayCollection;
use FacturadorVirtualModelosSeguridadUsuario;
/**
* @entity
* @table(name="planes_adquiridos")
*/
class PlanAdquirido
{
/**
* @id
* @var integer
* @column(type="integer", name="id_plan")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var Usuario
* @ManyToOne(targetEntity="FacturadorVirtualModelosSeguridadUsuario")
* @JoinColumn(name="adquirido_por", referencedColumnName="id_usuario")
*/
protected $adquiridoPor;
}
If I run "vendor/bin/doctrine.bat" orm:validate-schema
in windows I get:
Mapping
-------
[OK] The mapping files are correct.
But in linux I get:
Mapping
-------
[FAIL] The entity-class FacturadorVirtualModelosPlanesPlanAdquirido mapping is invalid:
* The referenced column name 'id_plan' has to be a primary key column on the target entity class 'FacturadorVirtualModelosPlanesPlanAdquirido'.
* The referenced column name 'id_usuario' has to be a primary key column on the target entity class 'FacturadorVirtualModelosSeguridadUsuario'.
Column name
id_usuario
referenced for relation from FacturadorVirtualModelosPlanesPlanAdquirido towards FacturadorVirtualModelosSeguridadUsuario does not exist.
I do not know if I am missing something, but have I have two days trying to figure out why is not working in linux (where production will reside).
- Tables and column’s name are all in lower case, using MySQL 5.7
Advertisement
Answer
Today I found the answer. The problem was redi’s cache. Everytime the project was updated I ran the clear cache command:
"vendor/bin/doctrine" orm:clear-cache:metadata
I thought that this command already cleared the cache, but it did not. To clear the cache correcly just run:
$ redis-cli
> flushall
All works great now since then!