Switch parent back to a ForeignKeyField without a constraint

This commit is contained in:
Jake Moshenko 2015-11-17 16:07:21 -05:00
parent 3374e8c812
commit e252397292
2 changed files with 12 additions and 6 deletions

View file

@ -552,6 +552,9 @@ class UserRegion(BaseModel):
)
_ImageProxy = Proxy()
class Image(BaseModel):
# This class is intentionally denormalized. Even though images are supposed
# to be globally unique we can't treat them as such for permissions and
@ -574,7 +577,9 @@ class Image(BaseModel):
security_indexed = BooleanField(default=False)
security_indexed_engine = IntegerField(default=-1)
parent_id = IntegerField(index=True, null=True)
# We use a proxy here instead of 'self' in order to disable the foreign key constraint
parent = ForeignKeyField(_ImageProxy, index=True, null=True, related_name='children')
class Meta:
database = db
@ -587,6 +592,9 @@ class Image(BaseModel):
)
_ImageProxy.initialize(Image)
class RepositoryTag(BaseModel):
name = CharField()
image = ForeignKeyField(Image)