Skip to main content
Version: Next

SchemaComparator

Compares two Schemas and return an instance of SchemaDifference.

Index

Constructors

constructor

Methods

compare

  • 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.


    Parameters

    • fromSchema: DatabaseSchema
    • toSchema: DatabaseSchema
    • optionalinverseDiff: SchemaDifference

    Returns SchemaDifference

diffCollation

  • diffCollation(fromCollation, toCollation, tableDefault): boolean
  • from is the introspected DB state, to is the target metadata. A column-level COLLATE clause naming the table/database default is just verbose syntax for inheriting that default, so both sides are normalized — anything matching tableDefault collapses to undefined and compares equal to "no explicit collation". Comparison is case-insensitive on dialects that treat collation identifiers as case-insensitive (MySQL/MSSQL/SQLite); PostgreSQL's pg_collation.collname is case-sensitive and is compared verbatim.


    Parameters

    • optionalfromCollation: string
    • optionaltoCollation: string
    • optionaltableDefault: string

    Returns boolean

diffColumn

  • diffColumn(fromColumn, toColumn, fromTable, logging): Set<string>
  • Returns the difference between the columns


    Parameters

    • fromColumn: Column
    • toColumn: Column
    • fromTable: DatabaseTable
    • optionallogging: boolean

    Returns Set<string>

diffComment

  • diffComment(comment1, comment2): boolean
  • Parameters

    • optionalcomment1: string
    • optionalcomment2: string

    Returns boolean

diffEnumItems

  • diffEnumItems(items1, items2): boolean
  • Parameters

    • items1: string[] = []
    • items2: string[] = []

    Returns boolean

diffExpression

  • diffExpression(expr1, expr2): boolean
  • Parameters

    • expr1: string
    • expr2: string

    Returns boolean

diffForeignKey

  • diffForeignKey(key1, key2, tableDifferences): boolean

diffIndex

  • diffIndex(index1, index2): 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.


    Parameters

    Returns boolean

diffTable

  • Returns the difference between the tables fromTable and toTable. If there are no differences this method returns the boolean false.


    Parameters

    • fromTable: DatabaseTable
    • toTable: DatabaseTable
    • optionalinverseTableDiff: TableDifference

    Returns false | TableDifference

hasSameDefaultValue

  • hasSameDefaultValue(from, to): boolean

isIndexFulfilledBy

  • isIndexFulfilledBy(index1, index2): boolean
  • Checks if the other index already fulfills all the indexing and constraint needs of the current one.


    Parameters

    Returns boolean

parseJsonDefault

  • parseJsonDefault(defaultValue): null | string | Dictionary
  • Parameters

    • optionaldefaultValue: null | string

    Returns null | string | Dictionary