private void createIndexVolumes(final Connection connection,
                                    final Collection<VolumeGroup> volumeGroups,
                                    final Map<Integer, OldVolume> oldVolumes) throws SQLException {
        final String insertMigratedIndexVolume = "" +
                "INSERT INTO index_volume (" +
                " id," +
                " version," +
                " create_time_ms," +
                " create_user," +
                " update_time_ms," +
                " update_user," +
                " node_name," +
                " path," +
                " fk_index_volume_group_id," +
                " state," +
                " bytes_limit," +
                " bytes_used," +
                " bytes_free," +
                " bytes_total," +
                " status_ms)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

        for (final VolumeGroup volumeGroup : volumeGroups) {
            for (final int oldVolumeId : volumeGroup.getOldVolumeIds()) {
                final OldVolume oldVolume = oldVolumes.get(oldVolumeId);
                final int newVolumeId = currentVolumeId.incrementAndGet();

                try (final PreparedStatement insert = connection.prepareStatement(insertMigratedIndexVolume)) {
                    insert.setInt(1, newVolumeId);
                    insert.setInt(2, 1);
                    insert.setLong(3, oldVolume.crtMs);
                    insert.setString(4, oldVolume.crtUser);
                    insert.setLong(5, oldVolume.updMs);
                    insert.setString(6, oldVolume.updUser);
                    insert.setString(7, oldVolume.nodeName);
                    insert.setString(8, oldVolume.path);
                    insert.setInt(9, volumeGroup.id);
                    insert.setByte(10, oldVolume.status.getPrimitiveValue());
                    DbUtil.setLong(insert, 11, oldVolume.bytesLimit);
                    DbUtil.setLong(insert, 12, oldVolume.bytesUsed);
                    DbUtil.setLong(insert, 13, oldVolume.bytesFree);
                    DbUtil.setLong(insert, 14, oldVolume.bytesTotal);
                    DbUtil.setLong(insert, 15, oldVolume.statMs);
                    insert.executeUpdate();
                }

                volumeGroup.addVolumeIdMapping(oldVolume.id, newVolumeId);
            }
        }
    }
@return A map of index UUIDs to lists of the volumes they use. We'll need both, hence the map.
stroom-legacy/stroom-legacy-db-migration/src/main/java/stroom/legacy/db/migration/V07_00_00_1502__Index.java