BUG: When creating table, db indexes should be created from DataFrame indexes

Unfortunately my PR #8022 introduced a bug wherein database indexes are not created from DataFrame indexes.  This pull request fixes it, also introduces this feature for the legacy interface, and adds tests to make sure indexes are created as appropriate.