private void addressUpgrade(DBHandle handle, TaskMonitor monitor)
			throws IOException, CancelledException {

		String mapName = getFragAddressTableName(treeID);

		AddressRangeMapDB map = new AddressRangeMapDB(handle, addrMap.getOldAddressMap(),
			treeMgr.getLock(), mapName, errHandler, LongField.INSTANCE, true);
		if (map.isEmpty()) {
			return;
		}

		String name = record.getString(ProgramTreeDBAdapter.TREE_NAME_COL);
		monitor.setMessage("Upgrading Program Tree (" + name + ")...");

		// Upgrade ranges into temporary map
		DBHandle tmpDb = new DBHandle();
		try {
			tmpDb.startTransaction();

			monitor.initialize(map.getRecordCount());
			int count = 0;

			AddressRangeMapDB tmpMap = new AddressRangeMapDB(tmpDb, addrMap,
				new Lock("Tmp Upgrade"), mapName, errHandler, LongField.INSTANCE, false);

			AddressRangeIterator iter = map.getAddressRanges();
			while (iter.hasNext()) {
				monitor.checkCancelled();
				AddressRange range = iter.next();
				Address startAddr = range.getMinAddress();
				Address endAddr = range.getMaxAddress();
				Field value = map.getValue(startAddr);

				tmpMap.paintRange(startAddr, endAddr, value);

				monitor.setProgress(++count);
			}

			monitor.initialize(count);
			count = 0;

			map.dispose(); // deletes old map table

			// Copy ranges into new map
			map = new AddressRangeMapDB(handle, addrMap, treeMgr.getLock(), mapName, errHandler,
				LongField.INSTANCE, true);
			iter = tmpMap.getAddressRanges();
			while (iter.hasNext()) {
				monitor.checkCancelled();
				AddressRange range = iter.next();
				map.paintRange(range.getMinAddress(), range.getMaxAddress(),
					tmpMap.getValue(range.getMinAddress()));
				monitor.setProgress(++count);
			}

			tmpMap.dispose();
		}
		finally {
			tmpDb.close();
		}
	}
Construct a program tree module manager
@param treeMgr program tree manager
@param rec program tree record
@param openMode the mode this adapter is to be opened for (CREATE, UPDATE, READ_ONLY, UPGRADE).
@param monitor task monitor
@throws IOException if a database IO error occurs
@throws CancelledException if monitor cancelled (upgrade case only)
@throws VersionException if opening an existing program tree and an underlying table 
schema version differs from the expected version.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/module/ModuleManager.java