attachment: Make path_id field unique.

This will help avoid future bugs similar to that fixed in migration
0072.
This commit is contained in:
Tim Abbott 2017-04-13 15:30:23 -07:00
parent 0f855b84cc
commit b92385ea8e
2 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-04-13 22:29
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('zerver', '0074_fix_duplicate_attachments'),
]
operations = [
migrations.AlterField(
model_name='archivedattachment',
name='path_id',
field=models.TextField(db_index=True, unique=True),
),
migrations.AlterField(
model_name='attachment',
name='path_id',
field=models.TextField(db_index=True, unique=True),
),
]

View File

@ -1226,7 +1226,7 @@ class AbstractAttachment(ModelReprMixin, models.Model):
# path_id is a storage location agnostic representation of the path of the file.
# If the path of a file is http://localhost:9991/user_uploads/a/b/abc/temp_file.py
# then its path_id will be a/b/abc/temp_file.py.
path_id = models.TextField(db_index=True) # type: Text
path_id = models.TextField(db_index=True, unique=True) # type: Text
owner = models.ForeignKey(UserProfile) # type: UserProfile
realm = models.ForeignKey(Realm, blank=True, null=True) # type: Realm
is_realm_public = models.BooleanField(default=False) # type: bool