1
irmtfan
The best way to patch data in database
  • 2013/10/10 3:24

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


In some rare cases a developer need to patch some data in module table.
For example in userlog newer versions (1.1+) I add a feature to find all login/register attempts so I need to patch all previous logged login/register data in old installations.
So If somebody had userlog installed for one year, when he upgrade to newer version he can find all login/register history.
To implement patch, I decided to not add it in normal ways like:
1- module update process: because a) module update is for database structure not data b) data may be huge and may cause some bad behaviors.
2- a menu and button in module admin area: because it is just needed for one time and after patch is finished, user dont need that menu anymore.

So finally I decided to do it silently thru one file called userlog/class/patch/patch_login_history.php
Every time user goes to userlog > admin > statistics the above patch file will be executed and will patch data 100 by 100.
If patch file find no data to patch it will delete itself from server.
So for example in new installations the file will be deleted in the first visit of userlog > admin > statistics.
IMO this way is effective, accurate and easy.
The only problem I recently faced is a user may have a folder with chmode below 700 and dont let the module to delete a file.
So those users have to delete the patch file manually.(I can add a notice for them)
Please let me know your valuable opinions about this.

Login

Who's Online

153 user(s) are online (79 user(s) are browsing Support Forums)


Members: 0


Guests: 153


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits