Remove primary key EbookTagId

Add a SortOrder column so that tags are presented in the same order as listed in content.opf.
This commit is contained in:
Mike Colagrosso 2024-10-13 20:48:42 -06:00 committed by Alex Cabal
parent b4b6fde778
commit 4e8ba5ddaa
2 changed files with 6 additions and 6 deletions

View file

@ -144,7 +144,7 @@ class Ebook{
from Tags t
inner join EbookTags et using (TagId)
where EbookId = ?
order by et.EbookTagId
order by SortOrder asc
', [$this->EbookId], EbookTag::class);
}
@ -1691,13 +1691,14 @@ class Ebook{
}
private function AddTags(): void{
foreach($this->Tags as $tag){
foreach($this->Tags as $sortOrder => $tag){
try{
Db::Query('
INSERT into EbookTags (EbookId, TagId)
INSERT into EbookTags (EbookId, TagId, SortOrder)
values (?,
?,
?)
', [$this->EbookId, $tag->TagId]);
', [$this->EbookId, $tag->TagId, $sortOrder]);
}
catch(Exceptions\DuplicateDatabaseKeyException){
// The Ebook already has the Tag, which is fine.