ui / django-post_office

A Django app that allows you to send email asynchronously in Django. Supports HTML email, database backed templates and logging.
MIT License
1.01k stars 268 forks source link

Error on migration 0005 #266

Open TomasRezende opened 5 years ago

TomasRezende commented 5 years ago

Hi, I'm trying to install django-post-office but migration 0005 gives a constraint error. I have used it before for other projects, but this is the first time using it with django 2.1.8 and python 3.6.8.

Error:

  Applying post_office.0001_initial... OK
  Applying post_office.0002_add_i18n_and_backend_alias... OK
  Applying post_office.0003_longer_subject... OK
  Applying post_office.0004_auto_20160607_0901... OK
  Applying post_office.0005_auto_20170515_0013...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\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_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\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\core\management\base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\core\management\base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\core\management\commands\migrate.py", line 203, in handle
    fake_initial=fake_initial,
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\migrations\operations\models.py", line 514, in database_forwards
    getattr(new_model._meta, self.option_name, set()),
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\backends\base\schema.py", line 356, in alter_unique_together
    self._delete_composed_index(model, fields, {'unique': True}, self.sql_delete_unique)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\backends\mysql\schema.py", line 82, in _delete_composed_index
    return super()._delete_composed_index(model, fields, *args)
  File "C:\Users\Work\Documents\Git\proxy_provider\proxy_provider_env\lib\site-packages\django\db\backends\base\schema.py", line 385, in _delete_composed_index
    ", ".join(columns),
ValueError: Found wrong number (0) of constraints for post_office_emailtemplate(language, default_template_id)

I'm also using mysql as my database. Did anyone had this same problem? And if so how did you fixed?

jrief commented 5 years ago

From your log, I assume you applied it on a fresh database.

migration 0005_... is not that important (it just adds one unique together constraint on your database), so after that error happens, you can bypass it by invoking

./manage.py migrate --fake 0006
./manage.py migrate
Mogost commented 4 years ago

Most likely this issue can be closed.