Remove primary key EbookSourceId

There is a one to many relationship between `Ebook` and `EbookSource`, and we
don't query by `EbookSourceId`. We add a `SortOrder` column to keep the sources
in the same order as specified in `content.opf`.
This commit is contained in:
Mike Colagrosso 2024-10-13 20:59:06 -06:00 committed by Alex Cabal
parent 4e8ba5ddaa
commit 1076c9a77d
4 changed files with 19 additions and 9 deletions

View file

@ -193,7 +193,7 @@ class Ebook{
SELECT *
from EbookSources
where EbookId = ?
order by EbookSourceId
order by SortOrder asc
', [$this->EbookId], EbookSource::class);
}
@ -1790,8 +1790,9 @@ class Ebook{
* @throws Exceptions\ValidationException
*/
private function AddSources(): void{
foreach($this->Sources as $source){
foreach($this->Sources as $sortOrder => $source){
$source->EbookId = $this->EbookId;
$source->SortOrder = $sortOrder;
$source->Create();
}
}