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

Migrate error after add new field #160

Closed
LongVuTran opened this issue Oct 4, 2019 · 1 comment
Closed

Migrate error after add new field #160

LongVuTran opened this issue Oct 4, 2019 · 1 comment

Comments

@LongVuTran
Copy link

LongVuTran commented Oct 4, 2019

My model (migrate okay in the first time)

class Dkm(models.Model):
    name = fields.TextPGPSymmetricKeyField()
    value = fields.IntegerPGPSymmetricKeyField(default=0)

I update model and migrate again:

class Dkm(models.Model):
    name = fields.TextPGPSymmetricKeyField()
    value = fields.IntegerPGPSymmetricKeyField(default=0)
    value3 = fields.IntegerPGPSymmetricKeyField(default=0)

Error occur:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\core\management\base.py", line 364, in execute
    cursor.execute(sql, params)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 99, in execute
    return super().execute(sql, params)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\vu.tran\Desktop\kona-server\env\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "value3" is of type bytea but default expression is of type integer
HINT:  You will need to rewrite or cast the expression.

The error will not occur if set null=True
Have you got any idea?

@maestrofjp
Copy link

We'd need more information to help diagnose the issue. We have guidance on how to open an issue:

https://github.com/incuna/django-pgcrypto-fields/blob/master/CONTRIBUTING.md#report-bugs

Likely, there is a misconfiguration of your application or missing pgcrypto extension at the db level.

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

No branches or pull requests

3 participants