Vapor предлагает что-то вроде:
static func prepare(on connection: MySQLConnection) -> Future<Void> {
return Database.create(self, on: connection) { builder in
builder.field(for: \.iq, type: .int, .default(.literal("123456")))
...
, это также должно работать с датами.
Или вы можете попытаться установить их в пользовательском init:
required init(id:Int?, adressLine1:String, adressLine2:String?, city:String, state:String, zip:String) {
self.id = id
self.adressLine1 = adressLine1
self.adressLine2 = adressLine2
self.city:String = city:String
self.state = state
self.zip = zip
self.createdAt = Date() //<---- here
self.updatedAt = Date() //<---- here
self.deletedAt = Date() //<---- here
}
или:
required init(id:Int?, adressLine1:String, adressLine2:String?, city:String, state:String, zip:String,
createdAt:Date = Date()/*<--- here*/, updatedAt:Date = Date()/*<--- here*/,deletedAt:Date = Date()/*<--- here*/) {
self.id = id
self.adressLine1 = adressLine1
self.adressLine2 = adressLine2
self.city:String = city:String
self.state = state
self.zip = zip
self.createdAt = createdAt
self.updatedAt = updatedAt
self.deletedAt = deletedAt
}