Tuesday, 31 January 2012

Tip for checking for database changes from an app

When testing for database changes while running an app.

Make a database dump just before you make a change

Dump as a sql file - phpmyadmin->export or pgadmin3->backup (select 'insert commands' in the options will be easier to read)

Do what you need to do then repeat the above.

Name the dumps as beforeaction.sql and afteraction.sql

Then from a terminal enter

diff -u -s beforeaction.sql afteraction.sql > changes.txt

Open changes.txt in your favourite editor.

Any line beginning with a +INSERT will be a new record.

Any lines beginning with -INSERT will have a matching +INSERT and will be an UPDATE - just look for the differences in the columns.

Thats it :)

No comments:

Post a Comment