Migrate v1 to v2
Umami v2 introduces a redesigned schema and a number of breaking changes.
Breaking changes#
- The API endpoints have changed including new ones being added. See API for more information.
- The tracker script has been renamed from
umami.jstoscript.js. - The collect api endpoint has been renamed from
/api/collectto/api/send. - The tracker no longer uses CSS class names to trigger events. It now uses HTML data attributes. See Track events for more information.
- The methods on the global
umamiJavaScript object have changed. There is now a single.track()method and a new way to send event data. See Tracker functions for more information. - The
TRACKER_SCRIPT_NAMEenvironment variable no longer appends the.jsextension to the script name. See Environment variables for more information.
Data migration#
Due to the schema changes, your data in your v1 database needs to be converted into v2.
To assist with the migration we created a script @umami/migrate-v1-v2 that will migrate all of your data for you.
Requirements#
- Database schema must be in sync with the latest v1 version (v1.4.0). The script will query the prisma migrations table to ensure the latest migrations have been run.
- Backup your target database prior to use. Potential data loss may occur if the migration is interrupted.
- For users with larger datasets (5M+), the migration may take a while. Please plan accordingly.
- The script will NOT migrate any event data into v2.
- The script will ask you if you want to drop your v1 tables after the migration is complete.
- If an
event_datatable is found populated with data, it will be renamed tov1_event_databut not dropped.
- If your
DATABASE_URLis localhost and the migration can't connect to the database, try changing to an IP address, for example:127.0.0.1.
Running migration#
There are two ways to run the migration script.
Running inside the Umami folder#
Use this method if you have terminal access to your application folder.
Make sure your application is already built. If not run yarn build first.
Running standalone#
Use this method if you don't have access to your application folder like when deployed to Vercel or Netlify.
Install
Configure
Create an .env file with the following variable defined:
Run
Docker migration#
Go into your running Docker container. You can find the name by the output of docker ps.
Run the migration script.
When the migration is run successfully, it should look like this: