thiagopena / djangoSIGE

Sistema Integrado de Gestão Empresarial baseado em Django
http://djangosige.com.br
MIT License
423 stars 252 forks source link

Erro no migrate #64

Closed renato04 closed 5 years ago

renato04 commented 5 years ago

Oi Tudo bem?

Estou tentando rodar pela primeira vez e ao rodar o python manage.py migrate acontece esse erro

(venv) G:\repos\djangoSIGE>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, cadastro, compras, contenttypes, estoque, financeiro, fiscal, login, sessions, vendas
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying login.0001_initial... OK
  Applying cadastro.0001_initial... OK
  Applying estoque.0001_initial... OK
  Applying vendas.0001_initial... OK
  Applying compras.0001_initial... OK
  Applying compras.0002_auto_20170625_1450... OK
  Applying fiscal.0001_initial... OK
  Applying cadastro.0002_auto_20170625_1450... OK
  Applying cadastro.0003_auto_20170714_1703... OK
  Applying cadastro.0004_auto_20170820_1448... OK
  Applying compras.0003_auto_20170820_1448... OK
  Applying estoque.0002_initial_data...Installed 1 object(s) from 1 fixture(s)
 OK
  Applying estoque.0002_auto_20170625_1450... OK
  Applying estoque.0003_merge_20170625_1454... OK
  Applying estoque.0004_auto_20170820_1448... OK
  Applying financeiro.0001_initial... OK
  Applying financeiro.0002_auto_20170820_1448... OK
  Applying financeiro.0003_auto_20170820_1808... OK
  Applying fiscal.0002_auto_20170820_1448... OK
  Applying fiscal.0003_auto_20170915_0904... OK
  Applying sessions.0001_initial... OK
  Applying vendas.0002_auto_20170820_1448... OK
Traceback (most recent call last):
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "auth_permission_content_type_id_codename_01ab375a_uniq"
DETAIL:  Key (content_type_id, codename)=(9, view_categoria) already exists.

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

Traceback (most recent call last):
  File "manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\core\management\base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\core\management\base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\core\management\commands\migrate.py", line 226, in handle
    self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\core\management\sql.py", line 51, in emit_post_migrate_signal
    **kwargs
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\dispatch\dispatcher.py", line 175, in send
    for receiver in self._live_receivers(sender)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\dispatch\dispatcher.py", line 175, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\contrib\auth\management\__init__.py", line 79, in create_permissions
    Permission.objects.using(using).bulk_create(perms)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\models\query.py", line 465, in bulk_create
    ids = self._batched_insert(objs_without_pk, fields, batch_size)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\models\query.py", line 1149, in _batched_insert
    inserted_id = self._insert(item, fields=fields, using=self.db, return_id=True)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\models\query.py", line 1136, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1289, in execute_sql
    cursor.execute(sql, params)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\backends\utils.py", line 100, in execute
    return super().execute(sql, params)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\backends\utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "G:\repos\djangoSIGE\venv\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "auth_permission_content_type_id_codename_01ab375a_uniq"
DETAIL:  Key (content_type_id, codename)=(9, view_categoria) already exists.
WilliamCampolina commented 5 years ago

aconteceu isto comigo, pra resolver eu usei uma versão anterior do django e não a que esta no requirements.txt, tente usar a versão 2.0

renato04 commented 5 years ago

@WilliamCampolina após rodar usando o django 2.0 parece que fucinou. Muito obrigado. Só me preocupa o django reclamar de constraint dependendo da versão. Porque eu não deletei a base criada pela versão mais nova e para a versão 2.0 está tudo aplicado. Vou fazer uns testes pra ver se consigo usar o sistema corretamente

(venv) G:\repos\djangoSIGE>python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, cadastro, compras, contenttypes, estoque, financeiro, fiscal, login, sessions, vendas
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
WilliamCampolina commented 5 years ago

me parece q alguém fez a correção ... só não me lembro se submeteu o pull request... quando fui instalar li em algumas issues sobre este erro ...

renato04 commented 5 years ago

Tem esse pull request aqui. Ja foi mergeado, mas o problema continua.