[ENTITY][NoteTag] Add 'canonical' field to tag

This commit is contained in:
Hugo Sales 2021-09-18 14:09:14 +01:00
parent 04174bc56d
commit 556b8f8265
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -20,6 +20,7 @@
namespace App\Entity;
use App\Core\Entity;
use Component\Tag\Tag;
use DateTimeInterface;
/**
@ -41,6 +42,7 @@ class NoteTag extends Entity
// {{{ Autocode
// @codeCoverageIgnoreStart
private string $tag;
private string $canonical;
private int $note_id;
private \DateTimeInterface $created;
@ -55,6 +57,17 @@ class NoteTag extends Entity
return $this->tag;
}
public function setCanonical(string $canonical): self
{
$this->canonical = $canonical;
return $this;
}
public function getCanonical(): string
{
return $this->canonical;
}
public function setNoteId(int $note_id): self
{
$this->note_id = $note_id;
@ -86,7 +99,8 @@ class NoteTag extends Entity
'name' => 'note_tag',
'description' => 'Hash tags on notes',
'fields' => [
'tag' => ['type' => 'varchar', 'length' => 64, 'not null' => true, 'description' => 'hash tag associated with this note'],
'tag' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'hash tag associated with this note'],
'canonical' => ['type' => 'varchar', 'length' => Tag::MAX_TAG_LENGTH, 'not null' => true, 'description' => 'ascii slug of hash tag'],
'note_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Note.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'foreign key to tagged note'],
'created' => ['type' => 'datetime', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
],
@ -94,6 +108,7 @@ class NoteTag extends Entity
'indexes' => [
'note_tag_created_idx' => ['created'],
'note_tag_note_id_idx' => ['note_id'],
'note_tag_canonical_idx' => ['canonical'],
'note_tag_tag_created_note_id_idx' => ['tag', 'created', 'note_id'],
],
];