69 lines
2.9 KiB
TypeScript
69 lines
2.9 KiB
TypeScript
import { type Dictionary } from '@mikro-orm/core';
|
|
import type { Column, ForeignKey, IndexDef, SchemaDifference, TableDifference } from '../typings.js';
|
|
import type { DatabaseSchema } from './DatabaseSchema.js';
|
|
import type { DatabaseTable } from './DatabaseTable.js';
|
|
import type { AbstractSqlPlatform } from '../AbstractSqlPlatform.js';
|
|
/**
|
|
* Compares two Schemas and return an instance of SchemaDifference.
|
|
*/
|
|
export declare class SchemaComparator {
|
|
#private;
|
|
constructor(platform: AbstractSqlPlatform);
|
|
/**
|
|
* Returns a SchemaDifference object containing the differences between the schemas fromSchema and toSchema.
|
|
*
|
|
* The returned differences are returned in such a way that they contain the
|
|
* operations to change the schema stored in fromSchema to the schema that is
|
|
* stored in toSchema.
|
|
*/
|
|
compare(fromSchema: DatabaseSchema, toSchema: DatabaseSchema, inverseDiff?: SchemaDifference): SchemaDifference;
|
|
/**
|
|
* Returns the difference between the tables fromTable and toTable.
|
|
* If there are no differences this method returns the boolean false.
|
|
*/
|
|
diffTable(
|
|
fromTable: DatabaseTable,
|
|
toTable: DatabaseTable,
|
|
inverseTableDiff?: TableDifference,
|
|
): TableDifference | false;
|
|
/**
|
|
* Try to find columns that only changed their name, rename operations maybe cheaper than add/drop
|
|
* however ambiguities between different possibilities should not lead to renaming at all.
|
|
*/
|
|
private detectColumnRenamings;
|
|
/**
|
|
* Try to find indexes that only changed their name, rename operations maybe cheaper than add/drop
|
|
* however ambiguities between different possibilities should not lead to renaming at all.
|
|
*/
|
|
private detectIndexRenamings;
|
|
diffForeignKey(key1: ForeignKey, key2: ForeignKey, tableDifferences: TableDifference): boolean;
|
|
/**
|
|
* Returns the difference between the columns
|
|
*/
|
|
diffColumn(fromColumn: Column, toColumn: Column, fromTable: DatabaseTable, logging?: boolean): Set<string>;
|
|
diffEnumItems(items1?: string[], items2?: string[]): boolean;
|
|
diffComment(comment1?: string, comment2?: string): boolean;
|
|
/**
|
|
* Finds the difference between the indexes index1 and index2.
|
|
* Compares index1 with index2 and returns index2 if there are any differences or false in case there are no differences.
|
|
*/
|
|
diffIndex(index1: IndexDef, index2: IndexDef): boolean;
|
|
/**
|
|
* Checks if the other index already fulfills all the indexing and constraint needs of the current one.
|
|
*/
|
|
isIndexFulfilledBy(index1: IndexDef, index2: IndexDef): boolean;
|
|
/**
|
|
* Compare advanced column options between two indexes.
|
|
*/
|
|
private compareIndexColumns;
|
|
/**
|
|
* Compare two arrays for equality (order matters).
|
|
*/
|
|
private compareArrays;
|
|
diffExpression(expr1: string, expr2: string): boolean;
|
|
parseJsonDefault(defaultValue?: string | null): Dictionary | string | null;
|
|
hasSameDefaultValue(from: Column, to: Column): boolean;
|
|
private mapColumnToProperty;
|
|
private log;
|
|
}
|