Added database migration for new entities.

This commit is contained in:
Jan Böhmer 2019-08-12 18:04:53 +02:00
parent 7826e3d2ad
commit 408d98c6e1
25 changed files with 246 additions and 99 deletions

View file

@ -64,6 +64,9 @@ use Symfony\Component\Serializer\Annotation\Groups;
*/
abstract class NamedDBElement extends DBElement
{
use TimestampTrait;
/**
* @var string The name of this element.
* @ORM\Column(type="string")
@ -72,20 +75,6 @@ abstract class NamedDBElement extends DBElement
*/
protected $name = '';
/**
* @var \DateTime The date when this element was modified the last time.
* @ORM\Column(type="datetimetz", name="last_modified")
* @Groups({"extended", "full"})
*/
protected $lastModified;
/**
* @var \DateTime The date when this element was created.
* @ORM\Column(type="datetimetz", name="datetime_added")
* @Groups({"extended", "full"})
*/
protected $addedDate;
/********************************************************************************
*
* Getters
@ -105,28 +94,6 @@ abstract class NamedDBElement extends DBElement
return $this->name;
}
/**
* Returns the last time when the element was modified.
* Returns null if the element was not yet saved to DB yet.
*
* @return \DateTime|null The time of the last edit.
*/
public function getLastModified(): ?\DateTime
{
return $this->lastModified;
}
/**
* Returns the date/time when the element was created.
* Returns null if the element was not yet saved to DB yet.
*
* @return \DateTime|null The creation time of the part.
*/
public function getAddedDate(): ?\DateTime
{
return $this->addedDate;
}
/********************************************************************************
*
* Setters
@ -157,19 +124,7 @@ abstract class NamedDBElement extends DBElement
*
******************************************************************************/
/**
* Helper for updating the timestamp. It is automatically called by doctrine before persisting.
*
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updatedTimestamps(): void
{
$this->lastModified = new \DateTime('now');
if (null === $this->addedDate) {
$this->addedDate = new \DateTime('now');
}
}
public function __toString()
{