| 119 | ==== Dealing with database corruption ==== |
| 120 | We had problems with the or_organisation table - queries wouldn't complete. |
| 121 | |
| 122 | The tracebacks included: {{{ValueError: invalid literal for int() with base 10: '01/14/10 1'}}} |
| 123 | To fix this we needed to: |
| 124 | * Delete column from model |
| 125 | {{{ |
| 126 | vim /home/haiti/prod/models/05_or.py |
| 127 | |
| 128 | resource = 'organisation' |
| 129 | table = module + '_' + resource |
| 130 | db.define_table(table, timestamp, deletion_status, |
| 131 | # uuidstamp |
| 132 | }}} |
| 133 | * Export as CSV |
| 134 | {{{ |
| 135 | cd /home/haiti/web2py |
| 136 | python web2py.py -S prod -M -N |
| 137 | db.or_organisation.export_to_csv_file(open('prod_orgs.csv','wb')) |
| 138 | Ctrl+D |
| 139 | }}} |
| 140 | * Drop table |
| 141 | {{{ |
| 142 | cd /home/haiti/web2py |
| 143 | python web2py.py -S prod -M -N |
| 144 | db.or_organisation.drop() |
| 145 | db.commit() |
| 146 | Ctrl+D |
| 147 | }}} |
| 148 | * Rebuild Table |
| 149 | * Ensuring that table is owned by www-data |
| 150 | * http://haiti.sahanafoundation.org |
| 151 | * Reimport from CSV |
| 152 | {{{ |
| 153 | cd /home/haiti/web2py |
| 154 | python web2py.py -S prod -M -N |
| 155 | db.or_organisation.import_from_csv_file(open('prod_orgs.csv','rb')) |
| 156 | db.commit() |
| 157 | Ctrl+D |
| 158 | }}} |