Skip to content

Commit

Permalink
updated migration readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyofrancis committed Apr 19, 2018
1 parent bbabe7a commit 5166523
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,27 +303,29 @@ implementation "com.tonyodev.fetchmigrator:fetchmigrator:2.0.0-RC15"
Then run the Migrator.
```java
try {
final String fetch2Namespace = "Main";
FetchMigrator.migrateFromV1toV2(this, fetch2Namespace);
FetchMigrator.deleteFetchV1Database(this);
final Fetch fetch = new Fetch.Builder(context, fetch2Namespace)
.setDownloadConcurrentLimit(4) // Allows Fetch to download 4 downloads in Parallel.
.enableLogging(true)
.build();
fetch.getDownloads(new Func<List<? extends Download>>() {
@Override
public void call(List<? extends Download> downloads) {
/* All downloads from the first version of Fetch
* will now be maintained, downloaded and monitored in version 2 of Fetch.
*/
if (didMigrationRun()) {
//Migration has to run on a background thread
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<DownloadTransferPair> transferredDownloads = FetchMigrator.migrateFromV1toV2(getApplicationContext(), APP_FETCH_NAMESPACE);
//TODO: update external references of ids
for (DownloadTransferPair transferredDownload : transferredDownloads) {
Log.d("newDownload", transferredDownload.getNewDownload().toString());
Log.d("oldId in Fetch v1", transferredDownload.getOldID() + "");
}
FetchMigrator.deleteFetchV1Database(getApplicationContext());
setMigrationDidRun(true);
//Setup and Run Fetch2 after the migration
} catch (SQLException e) {
e.printStackTrace();
}
}
}).start();
} else {
//Setup and Run Fetch2 normally
}
});
} catch (SQLException e) {
e.printStackTrace();
}
```
Contribute
Expand Down

0 comments on commit 5166523

Please sign in to comment.