Fixed upgrade.sql script