UNPKG

@yihuangdb/storage-object

Version:

A Node.js storage object layer library using Redis OM

61 lines 2.05 kB
/** * Schema Index Change Detector * * Utility to detect if schema changes affect indexed fields, * allowing optimization of index recreation during migrations. */ export interface SchemaFieldDefinition { type: 'text' | 'string' | 'number' | 'boolean' | 'date' | 'point' | 'string[]' | 'number[]'; indexed?: boolean; sortable?: boolean; normalized?: boolean; separator?: string; caseSensitive?: boolean; } export interface SchemaDefinition { [fieldName: string]: SchemaFieldDefinition; } export interface IndexChangeDetectionResult { hasIndexedFieldChanges: boolean; addedIndexedFields: string[]; removedIndexedFields: string[]; modifiedIndexedFields: string[]; safeNonIndexedChanges: string[]; } /** * Detects if schema changes affect indexed fields */ export declare class SchemaIndexDetector { /** * Compare two schemas and detect index-affecting changes */ static detectIndexChanges(oldSchema: SchemaDefinition, newSchema: SchemaDefinition): IndexChangeDetectionResult; /** * Check if an indexed field has changed in a way that requires index recreation */ private static hasIndexedFieldChanged; /** * Check if a non-indexed field has changed (safe changes) */ private static hasNonIndexedFieldChanged; /** * Detect index changes across multiple schema versions * Returns true if ANY version has index changes */ static detectIndexChangesAcrossVersions(schemaVersions: SchemaDefinition[]): { hasAnyIndexChanges: boolean; firstIndexChangeAt: number; lastIndexChangeAt: number; allChanges: IndexChangeDetectionResult[]; }; /** * Generate migration strategy based on detected changes */ static generateMigrationStrategy(changes: IndexChangeDetectionResult): { requiresIndexRecreation: boolean; migrationSteps: string[]; estimatedDowntime: string; }; } export default SchemaIndexDetector; //# sourceMappingURL=schema-index-detector.d.ts.map