Updating Database Schema - mkadin/sort GitHub Wiki

If you have data in a module's database tables, you can still update the scheme non-destructively.

  1. Go to Site Administration > Development > XMLDB Editor
  2. Click on "Load" and then "Edit" for the module you're editing.
  3. Add fields / tables etc.
  4. After making changes, click "Save" at the top level page. You may see a message complaining that the webserver can't write to install.xml. Apache needs write access to the install.xml file and its parent db directory. From the root of the module the following commands should do the trick:

chmod 777 db

cd db

chmod 777 install.xml

  1. For any new tables or fields, you want to click on 'view PHP code'. Make sure for the 'select action' drop down you select the appropriate action (i.e. add field), and that you add the correct field / table / key in the other drop down, and hit "view".
  2. Copy and paste the code given into the upgrade.php file and replace the XXXXXXXXXX with today's date and 00 (i.e. 2012100100 for October 1st 2012).
  3. Update the version.php to be the same date code.
  4. Backup your db.
  5. Go to admin/index.php and run the upgrade.