ngageoint / gamification-server

Server to track gamification elements (badges, points, tags) to work pages or apps
MIT License
243 stars 64 forks source link

DatabaseError: relation "badges_badge" does not exist #10

Closed moskrc closed 5 years ago

moskrc commented 9 years ago

$ paver createdb
---> pavement.createdb

Captured Task Output:
---------------------

---> pavement.createdb
Traceback (most recent call last):
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/paver/tasks.py", line 195, in _run_task
    return do_task()
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/paver/tasks.py", line 192, in do_task
    return func(**kw)
  File "pavement.py", line 87, in createdb
    from gamification import settings
  File "/Users/vit/projects/01.15/gamification-server/gamification/__init__.py", line 3, in <module>
    from gamification.core.models import Points
  File "/Users/vit/projects/01.15/gamification-server/gamification/core/models.py", line 143, in <module>
    from meta_badges import *
  File "/Users/vit/projects/01.15/gamification-server/gamification/core/meta_badges.py", line 30, in <module>
    class Gold(MetaBadge):
  File "/Users/vit/projects/01.15/gamification-server/gamification/badges/utils.py", line 94, in __new__
    return register(new_badge)
  File "/Users/vit/projects/01.15/gamification-server/gamification/badges/utils.py", line 18, in register
    registered_badges[badge.id] = badge()
  File "/Users/vit/projects/01.15/gamification-server/gamification/badges/utils.py", line 109, in __init__
    self._keep_badge_updated()
  File "/Users/vit/projects/01.15/gamification-server/gamification/badges/utils.py", line 145, in _keep_badge_updated
    badge, created = BadgeModel.objects.get_or_create(id=self.id)
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/models/manager.py", line 146, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/models/query.py", line 484, in get_or_create
    return self.get(**lookup), False
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/models/query.py", line 398, in get
    num = len(clone)
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/models/query.py", line 106, in __len__
    self._result_cache = list(self.iterator())
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/models/query.py", line 317, in iterator
    for row in compiler.results_iter():
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 775, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
    cursor.execute(sql, params)
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/backends/util.py", line 41, in execute
    return self.cursor.execute(sql, params)
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 58, in execute
    six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
  File "/Users/vit/projects/01.15/gamification-server/env/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 54, in execute
    return self.cursor.execute(query, args)
DatabaseError: relation "badges_badge" does not exist
LINE 1: ...badges_badge"."level", "badges_badge"."icon" FROM "badges_ba...
                                                             ^
stephenrjones commented 9 years ago

I've committed some changes that'll hopefully resolve this issue. Let me know if it works ok for you.

davidglevy commented 9 years ago

I just did a clone from the master and it's still occurring.

lingani commented 9 years ago

Hello @stephenrjones , I cloned both develop and master but no chance to get rid of this issue. please help!

sharmapawan commented 9 years ago

Hello, have you find any solution for this? I am also stuck in same error while setup.

ariel17 commented 9 years ago

Hello :) This occurs because the migration has an specific order to run: it needs to migrate first the core application and then badges application but Django orders them by name, a different criteria than the required one. I have created the pull request #17 forcing this dependency, along other changes.

sanpreet commented 6 years ago

It comes to me and I applied the command python manage.py syncdb. It therefore created table of my class whose object I am viewing and When I again run the command classname.objects.all() in python shell, it produces no error. So according to me, please synchdatabase so that database corresponding to your attributes in models.py is created which can be used further.