Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: table creation order fix #8

Merged
merged 1 commit into from
Oct 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion invenio_db/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def db():
def create(verbose):
"""Create tables."""
click.secho('Creating all tables!', fg='yellow', bold=True)
with click.progressbar(reversed(_db.metadata.sorted_tables)) as bar:
with click.progressbar(_db.metadata.sorted_tables) as bar:
for table in bar:
if verbose:
click.echo(' Creating table {0}'.format(table))
Expand Down
5 changes: 5 additions & 0 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@


class MockEntryPoint(EntryPoint):
"""Mocking of entrypoint."""

def load(self):
"""Mock load entry point."""
if self.name == 'importfail':
raise ImportError()
else:
Expand All @@ -61,6 +64,7 @@ def _mock_entry_points(name):


def test_init():
"""Test extension initialization."""
app = Flask('demo')
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
'SQLALCHEMY_DATABASE_URI', 'sqlite:///test.db'
Expand All @@ -75,6 +79,7 @@ class Demo(db.Model):
class Demo2(db.Model):
__tablename__ = 'demo2'
pk = sa.Column(sa.Integer, primary_key=True)
fk = sa.Column(sa.Integer, sa.ForeignKey(Demo.pk))

with app.app_context():
create_database(db.engine.url)
Expand Down