Added unique index for date field and replace/insert to update db.