Variable: exampleMigrations
constexampleMigrations: {httpV1_0_to_1_1:MigrationRule;portV1_0_to_1_1:MigrationRule; }
Defined in: electron/services/monitoring/MigrationSystem.ts:859
Example migration definitions for reference and testing.
Type Declaration
httpV1_0_to_1_1
httpV1_0_to_1_1:
MigrationRule
HTTP monitor migration: Adds a timeout field with default value.
Remarks
Non-breaking migration that adds a timeout field to HTTP monitor
configuration if not already present. Uses a safe default value and
preserves existing timeout values if they exist. Demonstrates the pattern
for adding optional fields during schema evolution.
Example
const migrated = await exampleMigrations.httpV1_0_to_1_1.transform({
url: "https://example.com",
});
// Result: { url: "https://example.com", timeout: 30000 }
Default Value
timeout = 30000 (30 seconds)
Param
The UnknownRecord monitor configuration data
Returns
Promise resolving to data with timeout field set
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error Should not throw for valid input data
portV1_0_to_1_1
portV1_0_to_1_1:
MigrationRule
Port monitor migration: Ensures port is numeric and valid.
Remarks
Converts string port numbers to integers and validates port range. Handles both string and numeric input, ensuring the port value is within the valid TCP/UDP port range (1-65535). Demonstrates data type conversion and validation patterns for migration rules.
Example
const migrated = await exampleMigrations.portV1_0_to_1_1.transform({
port: "8080",
});
// Result: { port: 8080 }
Param
The UnknownRecord monitor configuration data
Returns
Promise resolving to data with numeric port value
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When port value is invalid, not a number/string, or outside the valid range (1-65535)
Remarks
Provides template MigrationRule implementations for common migration scenarios. These examples demonstrate proper migration structure and are not registered by default. Register manually using migrationRegistry as needed for tests or new monitor types.
Contains migrations for HTTP and port monitor types that showcase typical migration patterns like adding fields with defaults and data type conversions.
Example
// Register example migrations
migrationRegistry.registerMigration("http", exampleMigrations.httpV1_0_to_1_1);
migrationRegistry.registerMigration("port", exampleMigrations.portV1_0_to_1_1);
// Use in tests
const result = await exampleMigrations.httpV1_0_to_1_1.transform({
url: "https://example.com",
});
See
migrationRegistry for registration of these examples