@yihuangdb/storage-object
Version:
A Node.js storage object layer library using Redis OM
57 lines • 1.96 kB
TypeScript
/**
* Schema Migration Manager
*
* Optimized schema migration with intelligent index recreation.
* Only recreates index when indexed fields change.
*/
import { RedisClientType } from 'redis';
import { Repository } from 'redis-om';
import { SchemaIndexDetector, SchemaDefinition, IndexChangeDetectionResult } from './schema-index-detector';
export interface SchemaMigration {
version: number;
schema: SchemaDefinition;
description?: string;
timestamp?: number;
}
export interface MigrationOptions {
dryRun?: boolean;
forceIndexRecreation?: boolean;
waitForIndexCompletion?: boolean;
progressCallback?: (message: string) => void;
}
export interface MigrationResult {
success: boolean;
migrationsApplied: number;
indexRecreated: boolean;
indexRecreationTime?: number;
totalTime: number;
steps: string[];
error?: string;
}
export declare class SchemaMigrationManager {
private redis;
private entityName;
constructor(redis: RedisClientType, entityName: string);
/**
* Apply multiple schema migrations with optimized index recreation
*/
applyMigrations(migrations: SchemaMigration[], currentSchema: SchemaDefinition, repository: Repository, options?: MigrationOptions): Promise<MigrationResult>;
/**
* Wait for index to complete background indexing
*/
private waitForIndexCompletion;
/**
* Analyze migration impact without applying changes
*/
static analyzeMigrationImpact(migrations: SchemaMigration[], currentSchema: SchemaDefinition): {
requiresIndexRecreation: boolean;
totalIndexedFieldChanges: number;
migrationDetails: Array<{
version: number;
changes: IndexChangeDetectionResult;
strategy: ReturnType<typeof SchemaIndexDetector.generateMigrationStrategy>;
}>;
};
}
export default SchemaMigrationManager;
//# sourceMappingURL=schema-migration-manager.d.ts.map