| 26 | ==== Changing a Column type in Sqlite live ==== |
| 27 | sqlite handles live migrations pretty well, however if there is existing data then a conversion from string to integer can cause problems. |
| 28 | For a development system, the easiest solution is simply to remove all {{{databases/*}}} & restart, however this isn't possible for a live system: |
| 29 | {{{ |
| 30 | vim /home/haiti/prod/models/00_db.py |
| 31 | migrate = True |
| 32 | |
| 33 | cd /home/haiti/prod |
| 34 | bzr pull |
| 35 | |
| 36 | cd /home/haiti/web2py |
| 37 | python web2py.py -S prod -M |
| 38 | |
| 39 | db(db.or_organisation.id > 0).select().export_to_csv_file(open('orgs.csv','wb')) |
| 40 | db.or_organisation.drop() |
| 41 | db.commit() |
| 42 | Ctrl+D |
| 43 | |
| 44 | python web2py.py -S prod -M |
| 45 | |
| 46 | db.or_organisation.import_from_csv_file(open('orgs.csv','rb')) |
| 47 | db.commit() |
| 48 | Ctrl+D |
| 49 | |
| 50 | /etc/init.d/apache2 force-reload |
| 51 | |
| 52 | vim /home/haiti/prod/models/00_db.py |
| 53 | migrate = False |
| 54 | |
| 55 | }}} |