User authentication is temporarily unavailable. If this situation persists, please inform your Wiki Admin.

To add a sql patch in Simple Invoices follow the steps below:

  • Write the sql for this patch in a way that wont mess with anyone data
    • that includes not changing the encoding of rows etc..
  • Once you've got the sql for the patch written open up the file include/sql_patches.php and copy the format of the other sql patches to create
    • $sql_patch_name_ is the name of the patch
      • ie. $sql_patch_name_8 = “Edit default invoice template field lenght to 50”;
    • $sql_patch_8 is the actual sql for the patch
      • ie. $sql_patch_8 = “ALTER TABLE si_defaults CHANGE def_inv_template def_inv_template VARCHAR( 50 ) DEFAULT NULL”;
    • $sql_patch_update_ is the sql to insert a row into the sql patchmanger table to say that the patch has been applied
      • ie. $sql_patch_update_8 = “INSERT INTO si_sql_patchmanager ( sql_id ,sql_patch_ref , sql_patch , sql_release , sql_statement ) VALUES (,8,'$sql_patch_name_8',20060526,)”;


  • Once the patch has been written the database_sqlpatches.php file has to be update to check and run this patch
    • open the file and add your patch to the run code
      • copy the format used for the other patches
        • ie. run_sql_patch(8,$sql_patch_name_8,$sql_patch_8,$sql_patch_update_8);
    • edit the file to add the sql for sql patch code
      • copy the format used for the other patches
        • ie. check_sql_patch(8,$sql_patch_name_8);


  • Now if you go to the Database Upgrade Manager page in Simple Invoices if will give you a list of all the patches that have and have not been applied, if alls well it should say that your newly added patch hasnt been applied.
  • To run the sql patch to make sure it works click the UPDATE button in the Database Upgrade Manager screen and Simple Invoices will check which patches have been applied and applied the ones that havent been applied. If this works fine you can commit you sql patch to subversion
 | wiki/how_to_write_a_sql_patch_for_simple_invoices.txt · Last modified: 2016/10/11 06:15 (external edit)