Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

engine.create_schema() fails to create tables #37

Open
dmitryzv opened this issue Feb 9, 2016 · 1 comment
Open

engine.create_schema() fails to create tables #37

dmitryzv opened this issue Feb 9, 2016 · 1 comment

Comments

@dmitryzv
Copy link

dmitryzv commented Feb 9, 2016

When there are more than 100 table in user's account and a table for a model already exists engine.create_schema() will fail with:
ResourceInUseException: Table already exists: table-name

This happens because in engine.py line 204 the call to:

        tablenames = set(self.dynamo.list_tables())

will return 100 first tables and in model_meta.py line 440:

        if tablename in tablenames:
            return None

will miss the fact that the table already exists.

Proposed solution:
For each table to create deliberately validate that it doesn't exist. Like (proto-code):

        for model in self._ddb_engine.models.itervalues():
            if not self._ddb_engine.dynamo.describe_table(model.meta_.ddb_tablename()):
                model.meta_.create_dynamo_schema(self._ddb_engine.dynamo, tablenames=[], wait=True)
@stevearc
Copy link
Owner

stevearc commented Feb 9, 2016

I think the solution might be easier than that. Old versions of dynamo3 had a default limit on list_tables of 100, but since 0.4.6 the default limit has been removed. Can you try pip install dynamo3>=0.4.6 and see if that fixes your problem?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants