Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Let's add my changes from "The Great WL Data Migration of 2012" #2

Merged
merged 1 commit into from

2 participants

@jewelia

No description provided.

@shazow shazow merged commit a8c838b into shazow:master
@shazow
Owner

You're awesome, thanks for making my life easier. :)

@jewelia

Awesome! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 15, 2012
  1. @jewelia
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 sqlalchemygrate/migrations.py
View
9 sqlalchemygrate/migrations.py
@@ -53,14 +53,15 @@ def table_migrate(e1, e2, table, table2=None, convert_fn=None, limit=100000):
if convert_fn:
r = []
for row in data:
- converted = convert_fn(table, row)
+ converted = convert_fn(row=row, old_table=table, new_table=table2)
if isinstance(converted, types.GeneratorType):
r += list(converted)
- else:
+ elif converted is not None:
r.append(converted)
data = r
- e2.execute(table2.insert(), data).close()
+ if data:
+ e2.execute(table2.insert(), data).close()
log.debug("-> Inserted {0} rows into: {1}".format(len(data), table2.name))
@@ -150,7 +151,7 @@ def migrate(e1, e2, metadata, convert_map=None, populate_fn=None, only_tables=No
if callable(populate_fn):
log.info("Running populate function.")
- populate_fn(metadata_from=metadata_old, metadata_to=metadata)
+ populate_fn(metadata_from=metadata_old, metadata_to=metadata_new)
for table in metadata_old.sorted_tables:
table_name = table.name
Something went wrong with that request. Please try again.