I’m working on an web application that needs a demo/example version, so that potential customers can see it in action. It uses some queries to create overviews like “list of invoices send in the last week”. In order to create a demo version with good examples, it would be best that these overviews are always the same.
The underlying database will probably be restored every night, using some backup. However, to make sure that the “list of invoices send in the last week” page always contains some results, the dates will need to be modified.
What would be the best way to achieve this? The application needs approx 50 tables (MySQL), all with an average of about 2 date/datetime fields. Creating a query that increases all this fields with 1 day would be a tedious job (and would need to be adjusted if more tables are added).
So I thought of the following: just use a static date on the demo website/server. This could be done by decreasing the server date by 1 every night, and this would ensure that the queries always retrieve the same results. Is this be a good solution for this problem, or would it introduce other problems?
I decided to do this otherwise. Changing the date of the server really feels like a hacky solution. Since the database is restored every night anyway, I have a mysqldump of the demo-data. I wrote a small script that searches for occurrences of dates in this dump, and increases these dates by one day. This script is run every night before restoring the dump into the database, and so far it works fine.
And in case someone is interested in the script. I’ve created it as a public gist: https://gist.github.com/2406317