Reputation: 9424
We use GRDB for our iOS application and am adding the following migration:
migrator.registerMigration("v7") { db in
try db.alter(table: "DocAlertThirdPartyTrackingUrl") { t in
t.add(column: DocAlertThirdPartyTrackingUrl.CodingKeys.initialDate.rawValue, .date).defaults(to: ?????)
}
}
Not sure how to set this up so it uses the current date as the default?
Upvotes: 1
Views: 243
Reputation: 51973
If you want a default value that is always the current date you need to do it at a database level so use the sql variant of the defaults function
.defaults(sql: "CURRENT_TIMESTAMP")
Upvotes: 1