grantmcconnaughey / django-field-history

A Django app to track changes to model fields.
BSD 3-Clause "New" or "Revised" License
314 stars 33 forks source link

relation "field_history_fieldhistory" does not exist on createinitialfieldhistory #29

Closed serdanilov closed 6 years ago

serdanilov commented 6 years ago

Hello!

I am using PostgreSQL and I'm getting the following error upon python manage.py createinitialfieldhistory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 28, in <module>
    execute_from_command_line(sys.argv)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/home/vagrant/grt/lib/python3.6/site-packages/field_history/management/commands/createinitialfieldhistory.py", line 37, in handle
    field_name=field).exists():
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/models/query.py", line 715, in exists
    return self.query.has_results(using=self.db)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/models/sql/query.py", line 516, in has_results
    return compiler.has_results()
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1031, in has_results
    return bool(self.execute_sql(SINGLE))
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1061, in execute_sql
    cursor.execute(sql, params)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/vagrant/grt/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "field_history_fieldhistory" does not exist
LINE 1: SELECT (1) AS "a" FROM "field_history_fieldhistory" WHERE ("...

my model:

class Title(models.Model):
    id = models.PositiveIntegerField(primary_key=True)
    name = models.CharField(max_length=255) 
    priority = models.PositiveIntegerField(null=True, blank=True)
    field_history = FieldHistoryTracker(['priority'])

tried doing this as well: https://django-field-history.readthedocs.io/en/latest/readme.html#working-with-mysql (just in case) - no success. What could be wrong?

edit: you have to use python manage.py migrate your new field first