migrations off for dry runs

pull/1/head
eric 2012-01-16 13:31:12 -05:00
parent 7affe92c8d
commit 61b81219cb
2 changed files with 46 additions and 43 deletions

View File

@ -22,29 +22,30 @@ class Migration(SchemaMigration):
db.create_unique('core_identifier', ['type', 'value'])
# migrating data
for work in orm.Work.objects.all():
if work.librarything_id:
identifier = orm.Identifier.objects.create(type='ltwk',value=work.librarything_id, work=work)
identifier.save()
if work.openlibrary_id:
identifier = orm.Identifier.objects.create(type='olwk',value=work.openlibrary_id, work=work)
identifier.save()
for edition in work.editions.all():
if edition.googlebooks_id:
identifier = orm.Identifier.objects.create(type='goog',value=edition.googlebooks_id, work=work, edition=edition)
if not db.dry_run:
for work in orm.Work.objects.all():
if work.librarything_id:
identifier = orm.Identifier.objects.create(type='ltwk',value=work.librarything_id, work=work)
identifier.save()
if edition.goodreads_id:
identifier = orm.Identifier.objects.create(type='gdrd',value=edition.goodreads_id, work=work, edition=edition)
identifier.save()
if edition.librarything_id:
identifier = orm.Identifier.objects.create(type='thng',value=edition.librarything_id, work=work, edition=edition)
identifier.save()
if edition.isbn_13:
identifier = orm.Identifier.objects.create(type='isbn',value=edition.isbn_13, work=work, edition=edition)
identifier.save()
if edition.oclc:
identifier = orm.Identifier.objects.create(type='oclc',value=edition.oclc, work=work, edition=edition)
if work.openlibrary_id:
identifier = orm.Identifier.objects.create(type='olwk',value=work.openlibrary_id, work=work)
identifier.save()
for edition in work.editions.all():
if edition.googlebooks_id:
identifier = orm.Identifier.objects.create(type='goog',value=edition.googlebooks_id, work=work, edition=edition)
identifier.save()
if edition.goodreads_id:
identifier = orm.Identifier.objects.create(type='gdrd',value=edition.goodreads_id, work=work, edition=edition)
identifier.save()
if edition.librarything_id:
identifier = orm.Identifier.objects.create(type='thng',value=edition.librarything_id, work=work, edition=edition)
identifier.save()
if edition.isbn_13:
identifier = orm.Identifier.objects.create(type='isbn',value=edition.isbn_13, work=work, edition=edition)
identifier.save()
if edition.oclc:
identifier = orm.Identifier.objects.create(type='oclc',value=edition.oclc, work=work, edition=edition)
identifier.save()

View File

@ -54,28 +54,30 @@ class Migration(SchemaMigration):
db.add_column('core_edition', 'librarything_id', self.gf('django.db.models.fields.CharField')(max_length=50, null=True), keep_default=False)
# migrating data
for identifier in orm.Identifier.objects.all():
if identifier.type=='ltwk':
identifier.work.librarything_id = identifier.value
identifier.work.save()
elif identifier.type=='olwk':
identifier.work.openlibrary_id = identifier.value
identifier.work.save()
elif identifier.type=='goog':
identifier.edition.googlebooks_id = identifier.value
identifier.edition.save()
elif identifier.type=='gdrd':
identifier.edition.goodreads_id = identifier.value
identifier.edition.save()
elif identifier.type=='thng':
identifier.edition.librarything_id = identifier.value
identifier.edition.save()
elif identifier.type=='isbn':
identifier.edition.isbn_13 = identifier.value
identifier.edition.save()
elif identifier.type=='oclc':
identifier.edition.oclc = identifier.value
identifier.edition.save()
if not db.dry_run:
for identifier in orm.Identifier.objects.all():
if identifier.type=='ltwk':
identifier.work.librarything_id = identifier.value
identifier.work.save()
elif identifier.type=='olwk':
identifier.work.openlibrary_id = identifier.value
identifier.work.save()
elif identifier.type=='goog':
identifier.edition.googlebooks_id = identifier.value
identifier.edition.save()
elif identifier.type=='gdrd':
identifier.edition.goodreads_id = identifier.value
identifier.edition.save()
elif identifier.type=='thng':
identifier.edition.librarything_id = identifier.value
identifier.edition.save()
elif identifier.type=='isbn':
identifier.edition.isbn_13 = identifier.value
identifier.edition.save()
elif identifier.type=='oclc':
identifier.edition.oclc = identifier.value
identifier.edition.save()
models = {