Modify table structure for getting historical data.
Get historical data. Add logging. Modify database globals.