Overview
This topic explains how to use LaunchDarkly SDKs to manage migrations or modernizations. You might use this feature if you are optimizing queries, upgrading to new tech stacks, migrating from one database to another, or other similar technology changes. This feature is available for server-side and edge SDKs only.Prerequisites
Before you configure your SDK to manage a migration, you must complete the following prerequisites:- Create a migration feature flag. This is a temporary flag used to migrate data or systems while keeping your application available and disruption free. Migration flags break up the switch from an old to a new implementation into a series of recommended stages where movement from one stage to the next is done in incremental steps.
- Determine how many stages your migration will have. You can select from the following options as part of creating a migration feature flag:
- Two stages: For migrations where you cannot run the new system and old system at the same time
- Four stages: For migrations that can run both the new and old systems at the same time
- Six stages: For migrations where you need to migrate
READSandWRITESseparatelyTo learn more, read Migration flags.
Use SDKs to manage a migration
Depending on how you created your migration feature flag, your migration will have two, four, or six stages. At each stage, you will be reading data from the old destination, the new destination, or both. You will also be writing data to the old destination, the new destination, or both. At each stage, only one of these destinations is considered the authoritative source. In the LaunchDarkly SDK, you can determine which stage of the migration your application is currently in, execute the appropriate read and write methods, and then compare the results to check correctness and view any errors or changes in latency. The following table describes the stages and which destination is authoritative. Remember that not all migrations will use all stages. | Stage | Read from | Write to- Configure the migration. In your SDK configuration, define how to read from and write to the old and new systems, how to check whether two reads are a match, and whether to track errors and latency metrics. To learn more, read Migration configuration.
- Call the read and write methods you defined, using the SDK’s migrator. The migrator determines the migration stage of the feature flag controlling the migration, and performs reads and writes to the old and new systems based on the migration stage.
Customize your migration
Customizing your migration is rare. If you have additional metrics that you want to track, or if your migration or modernization involves reading and writing from the new and old systems in a different configuration than the two, four, or six -stage migrations provided, you can also use the SDK to customize your migration. Here’s how:- Configure the migration. In your SDK configuration, define how to read from and write to the old and new systems, how to check whether two reads are a match, and whether to track errors and latency metrics. To learn more, read Migration configuration.
- Use the
migrationVariationmethod to evaluate your feature flag and determine the migration stage. - Use your own logic to perform the appropriate migration operations for the stage. Record any metrics that you are interested in.
- When the migration operation is complete, call the
trackMigrationmethod to record your metrics.
Server-side SDKs
This feature is available in the following server-side SDKs:.NET (server-side)
Expand .NET (server-side) code sample
Expand .NET (server-side) code sample
Read or Write. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:Read and Write.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use theMigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:TrackMigration method to record your metrics:IMigration, MigrationVariation, and TrackMigration.Go
Expand Go code sample
Expand Go code sample
Read or Write. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:Read and Write.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use theMigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns the migration stage, a tracker that you can use to build the analytics event to send back to LaunchDarkly, and an error.Here’s how:TrackMigrationOp method to record your metrics:Migration and TrackMigrationOp.Java
Expand Java code sample
Expand Java code sample
read or write. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:Migration.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns the migration stage, a tracker that you can use to build the analytics event to send back to LaunchDarkly, and an error.Here’s how:trackMigration method to record your metrics:migrationVariation and trackMigration.Node.js (server-side)
Expand Node.js (server-side) code sample
Expand Node.js (server-side) code sample
read or write methods from the LDMigration interface. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:LDMigration.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns a promise that is resolved with the result LDMigrationVariation. This result includes the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:trackMigration method to record your metrics:LDMigration. and LDMigrationOpEvent.PHP
Expand PHP code sample
Expand PHP code sample
read or write methods from the Migrator interface. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:Migrator.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:trackMigrationOperation method to record your metrics:Migrator and trackMigrationOperation.Python
Expand Python code sample
Expand Python code sample
read or write methods from the Migrator interface. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:ldclient.migrations.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigration_variation method to evaluate your feature flag and determine its migration stage. This method returns the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:track_migration_op method to record your metrics:ldclient.migrations and track_migration_op.Ruby
Expand Ruby code sample
Expand Ruby code sample
read or write. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:read and write.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigration_variation method to evaluate your feature flag and determine its migration stage. This method returns the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:track_migration_op method to record your metrics:Migrator and track_migration_op.Rust
Expand Rust code sample
Expand Rust code sample
read or write. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:read and write.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigration_variation method to evaluate your feature flag and determine its migration stage. This method returns the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:track_migration_op method to record your metrics:Migrator and track_migration_op.Edge SDKs
This feature is available in the following edge SDKs:Akamai
Expand Akamai code sample
Expand Akamai code sample
read or write methods from the LDMigration interface. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:LDMigration.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns a promise that is resolved with the result LDMigrationVariation. This result includes the migration stage. It also returns a tracker, which you can ignore. (The tracker is normally used to build an analytics event to send back to LaunchDarkly. However, the Akamai SDK does not support sending events, so there is no need to build one.)Here’s how:LDMigration.Cloudflare
Expand Cloudflare code sample
Expand Cloudflare code sample
read or write methods from the LDMigration interface. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:LDMigration.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns a promise that is resolved with the result LDMigrationVariation. This result includes the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:trackMigration method to record your metrics:LDMigration and LDMigrationOpEvent.Vercel
Expand Vercel code sample
Expand Vercel code sample
read or write methods from the LDMigration interface. The SDK evaluates the flag, determines which migration stage the flag is in, and performs the reads or writes in the appropriate system.Here’s how:LDMigration.You can check for consistency, errors, or latency under “Migration insights” on the Targeting tab of your migration flag in the LaunchDarkly user interface. To learn more, read Migration flags.Expand Customizing your migration
Expand Customizing your migration
Customizing your migration
Customizing your migration is rare. If you want to customize your migration, configure your migration information as before.Then, use themigrationVariation method to evaluate your feature flag and determine its migration stage. This method returns a promise that is resolved with the result LDMigrationVariation. This result includes the migration stage and a tracker that you can use to build the analytics event to send back to LaunchDarkly.Here’s how:trackMigration method to record your metrics:LDMigration and LDMigrationOpEvent.