Check database on first run, fix sql again