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 b6b7d0c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion djangoplugins/management/commands/syncplugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
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 b6b7d0c

Please sign in to comment.