Added sql to upgrade script. MUST ONLY BE RUN ONCE. fixes #376, closes #376