Fixed #19657 -- Made sql commands honour allow_syncdb

Thanks Manel Clos for the report and the initial patch.