Allow the namespace column to be null, and also non-unique. Fix the uncompressed size clobbering the size on the wire field. Add metadata constraints so that foreign key constraints get predictable names. Fix all downgrade migrations.

This commit is contained in:
Jake Moshenko 2014-10-02 10:46:20 -04:00
parent 2c5cc7990f
commit 5c18ffe67d
9 changed files with 53 additions and 28 deletions

View file

@ -1223,8 +1223,7 @@ def get_storage_by_uuid(storage_uuid):
return found
def set_image_size(docker_image_id, namespace_name, repository_name,
image_size):
def set_image_size(docker_image_id, namespace_name, repository_name, image_size, uncompressed_size):
try:
image = (Image
.select(Image, ImageStorage)
@ -1233,18 +1232,15 @@ def set_image_size(docker_image_id, namespace_name, repository_name,
.switch(Image)
.join(ImageStorage, JOIN_LEFT_OUTER)
.where(Repository.name == repository_name, Namespace.username == namespace_name,
Image.docker_image_id == docker_image_id)
Image.docker_image_id == docker_image_id)
.get())
except Image.DoesNotExist:
raise DataModelException('No image with specified id and repository')
if image.storage and image.storage.id:
image.storage.image_size = image_size
image.storage.save()
else:
image.image_size = image_size
image.save()
image.storage.image_size = image_size
image.storage.uncompressed_size = uncompressed_size
image.storage.save()
return image