Skip to content

Latest commit

 

History

History
105 lines (79 loc) · 3.92 KB

migration.md

File metadata and controls

105 lines (79 loc) · 3.92 KB

Migration Guides | GeoFire for JavaScript

Below are instructions for migrating from one version of GeoFire to another. If you are upgrading several versions at once, make sure you follow the migration instructions for all upgrades.

5.x.x to 6.x.x

With the release of GeoFire 6.0.0, GeoFire now uses the new Firebase Modular SDK. This new SDK is incompatible with previous versions, so if you're still using an older version of the Firebase SDK or our compat module, please stick to version 5.x.x of GeoFire.

This change only affects the way you interact with the Firebase SDK, but not how you interact with GeoFire.

For example, this:

// Initialize the Firebase SDK
firebase.initializeApp({
  // ...
});

// Create a Firebase reference where GeoFire will store its information
var firebaseRef = firebase.database().ref();

// Create a GeoFire index
var geoFire = new GeoFire(firebaseRef);

Becomes:

import { initializeApp } from 'firebase/app';
import { getDatabase, ref } from "firebase/database";

// Initialize the Firebase SDK
initializeApp({
  // ...
});

// Create a Firebase reference where GeoFire will store its information
var firebaseRef = ref(getDatabase());

// Create a GeoFire index
var geoFire = new GeoFire(firebaseRef);

See Firebase's upgrade guide for more details.

3.x.x to 4.x.x

Let's start off with the good news: RSVP is no longer required required at all to run GeoFire! That means you can remove RSVP entirely if you aren't using it elsewhere in your project.

The slightly bad news is that you may need to upgrade your Firebase dependency because GeoFire now uses the new promises functionality found in Firebase 2.4.0. Thankfully, upgrading should be as easy as upgrading the Firebase version you are using to 2.4.0 or higher (if it isn't already).

For you folks using GeoFire with npm, there is one more change you may have to make. With this release firebase is now a peer dependency of geofire instead of a regular dependency. As such, you will need to make sure firebase is listed as a regular dependency alongside geofire in your package.json (if it isn't already):

// package.json with GeoFire 3.x.x
{
  // ...
  "dependencies": {
    "geofire": "^3.0.0"
  },
  // ...
}

// package.json with GeoFire 4.x.x
{
  // ...
  "dependencies": {
    "firebase": "^2.4.0",
    "geofire": "^4.0.0"
  },
  // ...
}

3.0.x to 3.1.x

With the release of GeoFire 3.1.0, GeoFire now uses the new query functionality found in Firebase 2.0.0. As a result, you will need to upgrade to Firebase 2.x.x and add a new .indexOn rule to your Security and Firebase Rules to get the best performance. You can view the updated rules here and read our docs for more information about indexing your data.

2.x.x to 3.x.x

GeoFire 3.x.x has the same API as 2.x.x but uses a different underlying data structure to store its location data. If you are currently using 2.x.x and want to upgrade to 3.x.x, you must run the GeoFire 3.x.x migration script on your Firebase database. This Node.js script only needs to be run one time and should take only a few seconds to minutes depending on the size of your data. To run the script, copy the files in the migration/ folder to your machine and run the following commands:

$ npm install              # install needed dependencies
$ node migrateToV3.js      # display usage instructions