= Upgrades = [[TOC]] The basic process is: * Update your local development branch: {{{ git pull upstream master git push }}} * Refresh your Test instance with the current Production data {{{ clean test }}} * Upgrade the Test instance (which also migrates to the new DB schema): {{{ pull test }}} * Resolve any database migration issues that you encounter...documenting these for the script which you use to upgrade Prod * TEST * Enhance your migration script as-required to fix silent database migration issues - some of thesse can be found by reviewing the code changes for the modules which you are using * Repeat until happy * Backup Prod * Repeat upgrade script on Prod You may find this useful (especially if you have a smaller database...the process here takes too long for longer databases): * https://github.com/flavour/eden/blob/master/modules/s3migration.py == Example Scripts == === GIS Schema Migration === * http://eden.sahanafoundation.org/attachment/wiki/UserGuidelines/Admin/Upgrade/db_migration_4_gis.sh This is designed for use with uWSGI (i.e. Cherokee) - it will need minor tweaking to work with Apache/mod_WSGI (i.e. the part for stop/starting the service) It has been tested with both MySQL & PostgreSQL. * You should be running Web2Py 2.9.11+ for the proper Native JSON support if using Postgres. * Known Issues - style JSON can get corrupted so needs resaving - opacity/cluster_distance/cluster_threshold can need setting manually Usage: {{{ wget http://eden.sahanafoundation.org/raw-attachment/wiki/UserGuidelines/Admin/Upgrade/db_migration_4_gis.sh chmod +x db_migration_4_gis.sh clean test # Update the Test instance with current Prod data ./db_migration_4_gis.sh test }}} Test it out & confirm that all is working for you, then repeat for Prod: {{{ ./db_migration_4_gis.sh prod }}} == Old == === Fabfile === 1. Add the site to [http://eden.sahanafoundation.org/browser/static/scripts/tools/fabfile.py fabfile.py] 2. If no keys generated yet, then generate some: {{{ fab generate_keys }}} 3. deploy keys {{{ fab distribute_keys }}} 4. Run the upgrade (as/when required) {{{ fab deploy }}} === Older === Put site into Maintenance: {{{ vim /etc/crontab #0-59/1 * * * * www-data cd /path/to/web2py/ && python web2py.py -C -D 1 >> /tmp/cron.output 2>&1 vim /etc/apache/sites-available/maintenance RewriteEngine On RewriteRule ^/(.*) /maintenance.html ln -sf /etc/apache/sites-available/maintenance /etc/apache/sites-enabled/mysite /etc/init.d/apache2 force-reload }}} Update code: {{{ cd /path/to/web2py git pull upstream }}} Trial run: {{{ cd /path/to/web2py python web2py.py -S eden -M }}} Fix any Database Issues: 1. The .table files in the databases directory contains what web2py knows about your database 2. You need to set deployment_settings.base.migrate=True in {{{models/000_config.py}}} before you update the code and switch back to deployment_settings.base.migrate=False later on. 3. In case of database mismatches - check the databases directory for the appropriate {{{.table}}} file and change accordingly. If using [wiki:InstallationGuidelines/MySQL MySQL], then can use [http://phpmyadmin.net phpMyAdmin], if using SQLite then can use {{{sqlite3}}} command-line tool: * Linux: ({{{apt-get install sqlite3}}}) * Windows: http://www.sqlite.org/sqlite-3_6_23_1.zip * Documentation: http://www.sqlite.org/sqlite.html Restore site into production: {{{ vim /etc/crontab 0-59/1 * * * * www-data cd /path/to/web2py/ && python web2py.py -C -D 1 >> /tmp/cron.output 2>&1 ln -sf /etc/apache/sites-available/mysite /etc/apache/sites-enabled/mysite /etc/init.d/apache2 force-reload }}} == See Also == * MaintenanceGuidelines * UserGuidelines/Admin/DataMigration * BluePrintUpgrades * PakistanDeploymentCycle