rebuild sql for new database and rebuild part of program