Auctions schema and creation
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package schemas
|
||||
|
||||
import slick.jdbc.PostgresProfile.api._
|
||||
import models._
|
||||
import slick.jdbc.PostgresProfile.api.*
|
||||
import models.*
|
||||
import slick.lifted.ProvenShape
|
||||
import slick.model.ForeignKeyAction.Cascade
|
||||
import slick.model.ForeignKeyAction.{Cascade, Restrict}
|
||||
|
||||
import java.time.Instant
|
||||
|
||||
@@ -31,4 +31,22 @@ class AuthTokensTable(tag: Tag) extends Table[AuthToken](tag, "auth_tokens") {
|
||||
def user = foreignKey("users", userId, Users)(_.id, onDelete = Cascade)
|
||||
}
|
||||
|
||||
lazy val AuthTokens = TableQuery[AuthTokensTable]
|
||||
lazy val AuthTokens = TableQuery[AuthTokensTable]
|
||||
|
||||
class AuctionsTable(tag: Tag) extends Table[Auction](tag, "auctions") {
|
||||
def id = column[Int]("id", O.PrimaryKey, O.AutoInc)
|
||||
def name = column[String]("name")
|
||||
def gid = column[String]("gid", O.Unique)
|
||||
def authorId = column[Int]("author_id")
|
||||
def startingPrice = column[BigDecimal]("starting_price")
|
||||
def currentBid = column[Option[BigDecimal]]("current_bid")
|
||||
def currentBidderId = column[Option[Int]]("current_bidder_id")
|
||||
def currentBidAt = column[Option[Instant]]("current_bid_at")
|
||||
def createdAt = column[Instant]("created_at")
|
||||
|
||||
override def * : ProvenShape[Auction] = (id.?, name, gid, authorId, startingPrice, currentBid, currentBidderId, currentBidAt, createdAt).mapTo[Auction]
|
||||
|
||||
def author = foreignKey("users", authorId, Users)(_.id, onDelete = Restrict)
|
||||
}
|
||||
|
||||
lazy val Auctions = TableQuery[AuctionsTable]
|
||||
Reference in New Issue
Block a user