In my case this error was caused by wrong cache in moodledata folder. I moved Moodle to another server and wanted to launch it in the same server environment (same PHP version, same MySQL version), but got that error "Config table does not contain version while upgrading moodle". Removing everything in moodledata/cache and moodledata/temp solved the problem