Skip to content

Commit

Permalink
djangoplugins uniq constraint: use id instead of index
Browse files Browse the repository at this point in the history
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?)
  • Loading branch information
megies committed Jan 31, 2020
1 parent e185083 commit 19f631f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions djangoplugins/management/commands/syncplugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ def plugins(self, point, point_inst):
src = self.get_classes_dict(point.plugins)
dst = self.get_instances_dict(point_inst.plugin_set.all())

for _i, (plugin, inst) in enumerate(self.available(src, dst, Plugin)):
for plugin, inst in 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()
Expand Down
2 changes: 1 addition & 1 deletion djangoplugins/migrations/0002_add_id_to_plugins_uniq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')]),
),
]

0 comments on commit 19f631f

Please sign in to comment.