Merge pull request #300 from eikek/fix-joblog-order

Add counter to joblog for correct log order
This commit is contained in:
eikek 2020-10-02 22:22:22 +02:00 committed by GitHub
commit ba6645fcc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE "joblog"
ADD COLUMN "counter" bigint auto_increment;

View File

@ -0,0 +1,2 @@
ALTER TABLE `joblog`
ADD COLUMN `counter` mediumint auto_increment unique;

View File

@ -0,0 +1,2 @@
ALTER TABLE "joblog"
ADD COLUMN "counter" bigserial;

View File

@ -26,6 +26,10 @@ object RJobLog {
val created = Column("created")
val message = Column("message")
val all = List(id, jobId, level, created, message)
// separate column only for sorting, so not included in `all` and
// the case class
val counter = Column("counter")
}
import Columns._
@ -37,7 +41,7 @@ object RJobLog {
).update.run
def findLogs(id: Ident): ConnectionIO[Vector[RJobLog]] =
(selectSimple(all, table, jobId.is(id)) ++ orderBy(created.asc))
(selectSimple(all, table, jobId.is(id)) ++ orderBy(created.asc, counter.asc))
.query[RJobLog]
.to[Vector]