尽管执行 php bin/console 学说,但列未添加到数据库中的表中:schema:update --complete --force 命令
命令
php bin/console doctrine:schema:update --force
确实生成带有字段的实体。但是,当我尝试向现有实体添加字段时,它没有按预期工作。尽管该命令成功创建了初始实体及其字段,但在尝试通过添加新字段来修改现有实体时似乎遇到了问题。我在使用预先存在的实体的附加字段更新架构时遇到困难。
doctrine.yaml
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
# only needed for MySQL
charset: utf8mb4
default_table_options:
collate: utf8mb4_unicode_ci
mapping_types:
enum: string
server_version: 5.7
# Pour changer le mode sql pour supporter le NONE_FULL_GROUP_BY pour les requêtes sql
options:
1002: 'SET sql_mode=(SELECT REPLACE(@@sql_mode, "ONLY_FULL_GROUP_BY", ""))'
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
orm:
auto_generate_proxy_classes: false
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
dql:
string_functions:
WEEK: DoctrineExtensions\Query\Mysql\Week
MONTH: DoctrineExtensions\Query\Mysql\Month
YEAR: DoctrineExtensions\Query\Mysql\Year
datetime_functions:
TimestampDiff: DoctrineExtensions\Query\Mysql\TimestampDiff
mappings:
App:
is_bundle: false
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
when@test:
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname_suffix: '_test%env(default::TEST_TOKEN)%'
when@prod:
doctrine:
orm:
auto_generate_proxy_classes: false
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
实体:
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* Incident_collecte
*
* @author Alaa
*
* @ORM\Table(name="incident_collecte")
* @ORM\Entity(repositoryClass="App\Repository\IncidentCollecteRepository")
*
*/
class IncidentCollecte
{
---------
/**
* @ORM\Column(type="array", nullable=true)
*
* Table des meta-données d'un incident qui permet sa gestion, comme son état précédent
**/
private $metaData;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $UpdatedDateStatutFromPortal = null;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set dateCreation
*
* @param \DateTime $dateCreation
*
* @return IncidentCollecte
*/
public function setDateCreation($dateCreation)
{
$this->date_creation = $dateCreation;
return $this;
}
/**
* Get dateCreation
*
* @return \DateTime
*/
public function getDateCreation()
{
return $this->date_creation;
}
/**
* Set description
*
* @param string $description
*
* @return IncidentCollecte
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set idDemande.
*
* @param int $idDemande
*
* @return IncidentCollecte
*/
public function setIdDemande($idDemande)
{
$this->id_demande = $idDemande;
return $this;
}
/**
* Get idDemande.
*
* @return int
*/
public function getIdDemande()
{
return $this->id_demande;
}
/**
* Set dateCloture.
*
* @param \DateTime|null $dateCloture
*
* @return IncidentCollecte
*/
public function setDateCloture($dateCloture = null)
{
$this->date_cloture = $dateCloture;
return $this;
}
/**
* Get dateCloture.
*
* @return \DateTime|null
*/
public function getDateCloture()
{
return $this->date_cloture;
}
/**
* Set typeDemande.
*
* @param string|null $typeDemande
*
* @return IncidentCollecte
*/
public function setTypeDemande($typeDemande = null)
{
$this->type_demande = $typeDemande;
return $this;
}
/**
* Get typeDemande.
*
* @return string|null
*/
public function getTypeDemande()
{
return $this->type_demande;
}
/**
* Set cleDemande.
*
* @param string $cleDemande
*
* @return IncidentCollecte
*/
public function setCleDemande($cleDemande)
{
$this->cle_demande = $cleDemande;
return $this;
}
/**
* Get cleDemande.
*
* @return string
*/
public function getCleDemande()
{
return $this->cle_demande;
}
/**
* Set raisonCloture.
*
* @param string|null $raisonCloture
*
* @return IncidentCollecte
*/
public function setRaisonCloture($raisonCloture = null)
{
$this->raison_cloture = $raisonCloture;
return $this;
}
/**
* Get raisonCloture.
*
* @return string|null
*/
public function getRaisonCloture()
{
return $this->raison_cloture;
}
/**
* Set priorite.
*
* @param string $priorite
*
* @return IncidentCollecte
*/
public function setPriorite($priorite)
{
$this->priorite = $priorite;
return $this;
}
/**
* Get priorite.
*
* @return string
*/
public function getPriorite()
{
return $this->priorite;
}
/**
* Set etat.
*
* @param string $etat
*
* @return IncidentCollecte
*/
public function setEtat($etat)
{
$this->etat = $etat;
return $this;
}
/**
* Get etat.
*
* @return string
*/
public function getEtat()
{
return $this->etat;
}
/**
* Set regle.
*
* @param string|null $regle
*
* @return IncidentCollecte
*/
public function setRegle($regle = null)
{
$this->regle = $regle;
return $this;
}
/**
* Get regle.
*
* @return string|null
*/
public function getRegle()
{
return $this->regle;
}
/**
* Set DatePriseEnCompteClient.
*
* @param \DateTime|null $datePriseEnCompteClient
*
* @return IncidentCollecte
*/
public function setDatePriseEnCompteClient($dateMajClient = null)
{
$this->date_prise_en_compte_client = $dateMajClient;
return $this;
}
/**
* Get DatePriseEnCompteClient.
*
* @return \DateTime|null
*/
public function getDatePriseEnCompteClient()
{
return $this->date_prise_en_compte_client;
}
/**
* Set impact.
*
* @param string|null $impact
*
* @return IncidentCollecte
*/
public function setImpact($impact = null)
{
$this->impact = $impact;
return $this;
}
/**
* Get impact.
*
* @return string|null
*/
public function getImpact()
{
return $this->impact;
}
/**
* @return Collection|Siiv[]
*/
public function getSiiv(): Collection
{
return $this->siiv;
}
public function addSiiv(Siiv $siiv): self
{
if (!$this->siiv->contains($siiv)) {
$this->siiv[] = $siiv;
}
return $this;
}
public function removeSiiv(Siiv $siiv): self
{
$this->siiv->removeElement($siiv);
return $this;
}
/**
* Set collecteurLogs.
*
* @param string|null $collecteurLogs
*
* @return IncidentCollecte
*/
public function setCollecteurLogs($collecteurLogs = null)
{
$this->collecteur_logs = $collecteurLogs;
return $this;
}
/**
* Get collecteurLogs.
*
* @return string|null
*/
public function getCollecteurLogs()
{
return $this->collecteur_logs;
}
/**
* Set metaData.
*
* @param array|null $metaData
*
* @return IncidentCollecte
*/
public function setMetaData($metaData = null)
{
$this->metaData = $metaData;
return $this;
}
/**
* Get metaData.
*
* @return array|null
*/
public function getMetaData()
{
return $this->metaData;
}
/**
* @return string|null
*/
public function getNumoffense(): ?string
{
return $this->numoffense;
}
/**
*
* @param string|null $numoffense
* @return IncidentCollecte
*/
public function setNumoffense(?string $numoffense): IncidentCollecte
{
$this->numoffense = $numoffense;
return $this;
}
/**
* @return string|null
*/
public function getSeverity(): ?string
{
return $this->severity;
}
/**
* @param string|null $severity
* @return IncidentCollecte
*/
public function setSeverity(?string $severity): IncidentCollecte
{
$this->severity = $severity;
return $this;
}
public function getUpdatedDateStatutFromPortal(): ?\DateTimeInterface
{
return $this->UpdatedDateStatutFromPortal;
}
public function setUpdatedDateStatutFromPortal(?\DateTimeInterface $UpdatedDateStatutFromPortal): static
{
$this->UpdatedDateStatutFromPortal = $UpdatedDateStatutFromPortal;
return $this;
}
}
您是否尝试过仅使用注释而不是混合注释和 PHP 属性?