From b6b7d0cb8366968f58157f4fe5396cef60b9e39e Mon Sep 17 00:00:00 2001 From: Tobias Megies Date: Fri, 31 Jan 2020 14:06:18 +0100 Subject: [PATCH] djangoplugins uniq constraint: use id instead of index was getting error messages about duplicate keys, looks like the id counter is automatically incremented as a uniq field but that index field might not be as a plain integer field (not handled by postgres at all?) --- djangoplugins/management/commands/syncplugins.py | 2 +- djangoplugins/migrations/0002_add_id_to_plugins_uniq.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/djangoplugins/management/commands/syncplugins.py b/djangoplugins/management/commands/syncplugins.py index 178daf6..093419f 100644 --- a/djangoplugins/management/commands/syncplugins.py +++ b/djangoplugins/management/commands/syncplugins.py @@ -110,7 +110,7 @@ def plugins(self, point, point_inst): for _i, (plugin, inst) in enumerate(self.available(src, dst, Plugin)): inst.point = point_inst inst.name = getattr(plugin, 'name', None) - inst.index = _i + inst.id = getattr(plugin, 'id') if hasattr(plugin, 'title'): inst.title = six.text_type(getattr(plugin, 'title')) inst.save() diff --git a/djangoplugins/migrations/0002_add_id_to_plugins_uniq.py b/djangoplugins/migrations/0002_add_id_to_plugins_uniq.py index 0faebcc..2bdd5ee 100644 --- a/djangoplugins/migrations/0002_add_id_to_plugins_uniq.py +++ b/djangoplugins/migrations/0002_add_id_to_plugins_uniq.py @@ -14,6 +14,6 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( name='plugin', - unique_together=set([('point', 'name', 'index')]), + unique_together=set([('point', 'name', 'id')]), ), ]