Fix #19657: sql, sqlcustom, sqlindexes and sqlall do not take allow_syncdb into account

Simple fix for https://code.djangoproject.com/ticket/19657

Check was copied from other modules taking database routers into account.