Added history recording into database.