vendredi 29 avril 2016

Django move from sqlite to postgres problems with integer

I have problems to move on postgres db. I'm getting error "A server error occurred. Please contact the administrator." on page. In console i recive error when i try make migrate command:

Error:

Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying core.0002_auto_20160427_1326...Traceback (most recent call last):
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: ERROR:  column "revival" cannot be cast to type integer
HINT: "USING revival::integer".


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

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 5.0.2\helpers\pycharm\django_manage.py", line 41, in <module>
    run_module(manage_file, None, '__main__', True)
  File "C:\Program Files (x86)\Python35-32\Lib\runpy.py", line 182, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "C:\Program Files (x86)\Python35-32\Lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Program Files (x86)\Python35-32\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:/Users/loc/PycharmProjects/CRM\manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\management\__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\management\__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\management\base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\management\base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\core\management\commands\migrate.py", line 222, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\migrations\executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\migrations\executor.py", line 148, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\migrations\migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\migrations\operations\fields.py", line 201, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\base\schema.py", line 484, in alter_field
    old_db_params, new_db_params, strict)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\postgresql_psycopg2\schema.py", line 107, in _alter_field
    new_db_params, strict,
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\base\schema.py", line 636, in _alter_field
    params,
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\base\schema.py", line 111, in execute
    cursor.execute(sql, params)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\utils.py", line 98, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\loc\dJangoEnvironment\lib\site-packages\django\db\backends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: ERROR:  column "revival" cannot be cast to type integer
HINT: "USING revival::integer".


Process finished with exit code 1

model witch revival field:

class Task(models.Model):
    name = models.CharField(max_length=80, blank=True, null=True)
    deadline_date = models.DateField(null=True, blank=True)
    created_date = models.DateTimeField(auto_now_add=True, editable=False)
    finished_date = models.DateTimeField(null=True, blank=True)
    modified_date = models.DateTimeField(auto_now=True, editable=False)
    responsible_group = models.ForeignKey(Group)
    responsible_user = models.ForeignKey(User, blank=True, null=True, related_name='+')
    revival = models.IntegerField(blank=True, null=True)
    creator = models.ForeignKey(User, blank=True, null=True, related_name='+')
    modified_user = models.ForeignKey(User, blank=True, null=True, related_name='+')
    client = models.ForeignKey(Client, blank=True, null=True)
    order = models.OneToOneField(Order, blank=True, null=True, on_delete=models.CASCADE)
    platform = models.ForeignKey(Platform, blank=True, null=True, on_delete=models.PROTECT)
    comment = models.ForeignKey("Comment", blank=True, null=True, related_name='+')
    status = models.ForeignKey(TaskStatus, default=1, on_delete=models.PROTECT)

Can you give me some advice how to resolve this?

Aucun commentaire:

Enregistrer un commentaire