1
1
package de .upb .cs .swt .delphi .instanceregistry .daos
2
- import slick .jdbc .H2Profile .api ._
2
+ import java .sql .Timestamp
3
+
4
+ import akka .http .scaladsl .model .DateTime
5
+ import slick .jdbc .MySQLProfile
6
+ import slick .jdbc .MySQLProfile .api ._
3
7
import slick .sql .SqlProfile .ColumnOption .NotNull
4
8
5
9
class Instances (tag : Tag ) extends Table [(Long , String , Long , String , String , Option [String ], String , String )](tag, " instances" ) {
@@ -24,12 +28,19 @@ class InstanceMatchingResults(tag: Tag) extends Table[(Long, Long, Boolean)](tag
24
28
def * = (id, instanceId, matchingSuccessful)
25
29
}
26
30
27
- class InstanceEvents (tag : Tag ) extends Table [(Long , String , String )](tag, " instance_events" ) {
31
+ class InstanceEvents (tag : Tag ) extends Table [(Long , String , DateTime , String )](tag, " instance_events" ) {
28
32
def id = column[Long ](" id" , O .PrimaryKey , O .AutoInc ) // This is the primary key column
29
33
def eventType = column[String ](" eventType" , O .Length (100 ), NotNull )
34
+ def timestamp = column[DateTime ](" timestamp" , NotNull )
30
35
def payload = column[String ](" payload" , O .Length (1000 ), NotNull )
31
36
32
- def * = (id, eventType, payload)
37
+ def * = (id, eventType, timestamp, payload)
38
+
39
+ implicit def dateTime : MySQLProfile .BaseColumnType [DateTime ] =
40
+ MappedColumnType .base[DateTime , Timestamp ](
41
+ dt => new Timestamp (dt.clicks),
42
+ ts => DateTime (ts.getTime)
43
+ )
33
44
}
34
45
35
46
class EventMaps (tag : Tag ) extends Table [(Long , Long , Long )](tag, " event_maps" ) {
0 commit comments