Developers · Data
Migrating Data
Last updated 7 November 2026
This document guides you in using migrations when you need to change the data or execute a piece of code outside of the regular application running cycle. An example use case is when you want to seed data on different environments.
Prerequisites
To be able to follow the steps in this tutorial, you must understand basic Insites concepts, and the topics in the 'Get Started' section.
Steps
Migrating data is a three-step process:
- Step 1: Generate an empty migration
- Step 2: Implement the migration
- Step 3: Run the migration
Step 1: Generate an empty migration
Generate an empty migration using the
[user@host] $ | insites-cli migrations generate ENVIRONMENT MIGRATION_NAMEFor example:
[user@host] $ | insites-cli migrations generate local add_some_booksOn success, this generates an empty migration in the
[user@host] $ | insites-cli migrations list localPlease note that the name you provide will be prefixed with a UTC timestamp that looks like this:
This value is used to keep the migrations in order in all environments. Please do not change this value by hand; do not skip this step by simply adding a file in the
Step 2: Implement the migration
Use the Liquid markup in migration files, which includes executing GraphQL mutations (graphql tag). You can sync a migration file many times. For example, you can put the following mutation into the file created by the command in step 1:
{% graphql res = "create_book", name: "Animal Farm", author: "George Orwell" %}Note
Be careful about using deploys with migrations that are not ready, because deployment runs all migrations that are in pending status.
Step 3: Run the migration
Note
You can use deploy or sync, but the migration you want to execute has to be delivered to the target environment first.
The deployment will upload and try to run migrations one by one (ordered by timestamp). It will fail if one of the migrations fails. The
[user@host] $ | insites-cli migrations run MIGRATION_TIMESTAMP ENVIRONMENTFor example:
[user@host] $ | insites-cli migrations run 20180909123423 localNote
For the command, you have to provide the timestamp, not the full name, for example: 20180731120002
A newly created migration is in pending status for as long as it has not been run. Once it's executed (either through a deploy or the
You can check the status of all migrations using the
Once a migration is in the done status, you can't run it again - this makes it safer to run the same queue of migrations on all environments.
When an error occurs, check the migration's state and error messages with
[user@host] $ | insites-cli migrations status 20180909123423 localFix the migration file, sync or deploy it, then run it again with
[user@host] $ | insites-cli migrations retry 20180909123423 localYou can edit and rerun a failed migration until it succeeds.
Although migrations are run in a background worker and will not affect your site's performance, we encourage using Data Import/Export for larger data jobs. Migrations are best for seeding data and making minor changes to a Table.