Skip to content

Commit

Permalink
Merge pull request #50 from centralniak/fix/failing-migration-tofiler
Browse files Browse the repository at this point in the history
wrap migration in try except
  • Loading branch information
vinitkumar committed May 24, 2018
2 parents d50f7bc + eedb809 commit e657a70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions cmsplugin_gallery/migrations/0006_auto_20180411_1046.py
Expand Up @@ -12,16 +12,19 @@ def migrate_to_filer(apps, schema_editor):
GalleryImage = apps.get_model('cmsplugin_gallery', 'Image')
images = GalleryImage.objects.all()

for image in images:
if image.src:
image_src = Image.objects.get_or_create(
file=image.src.file,
defaults={
'name': image.src.name
}
)[0]

images.filter(pk=image.pk).update(image_src=image_src)
try:
for image in images:
if image.src:
image_src = Image.objects.get_or_create(
file=image.src.file,
defaults={
'name': image.src.name
}
)[0]

images.filter(pk=image.pk).update(image_src=image_src)
except Exception as e:
print e

class Migration(migrations.Migration):

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(
name='cmsplugin_gallery',
version='1.1.7',
version='1.1.8',
author='Piotr Kilczuk',
author_email='piotr@tymaszweb.pl',
url='http://github.com/centralniak',
Expand Down

0 comments on commit e657a70

Please sign in to comment.