Skip to main content
Version: 5.9

SchemaComparator

Compares two Schemas and return an instance of SchemaDifference.

Index

Constructors

constructor

  • new SchemaComparator(platform: AbstractSqlPlatform): SchemaComparator
  • Parameters

    • platform: AbstractSqlPlatform

    Returns SchemaComparator

Methods

compare

  • compare(fromSchema: DatabaseSchema, toSchema: DatabaseSchema): SchemaDifference
  • 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

    Returns SchemaDifference

diffCheck

  • diffCheck(check1: Check<unknown>, check2: Check<unknown>): boolean
  • Parameters

    • check1: Check<unknown>
    • check2: Check<unknown>

    Returns boolean

diffColumn

  • diffColumn(column1: Column, column2: Column, tableName?: string): Set<string>
  • Returns the difference between the columns If there are differences this method returns field2, otherwise the boolean false.


    Parameters

    • column1: Column
    • column2: Column
    • optionaltableName: string

    Returns Set<string>

diffComment

  • diffComment(comment1?: string, comment2?: string): boolean
  • Parameters

    • optionalcomment1: string
    • optionalcomment2: string

    Returns boolean

diffEnumItems

  • diffEnumItems(items1?: string[], items2?: string[]): boolean
  • Parameters

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

    Returns boolean

diffForeignKey

  • diffForeignKey(key1: ForeignKey, key2: ForeignKey): boolean
  • Parameters

    • key1: ForeignKey
    • key2: ForeignKey

    Returns boolean

diffIndex

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

    • index1: Index
    • index2: Index

    Returns boolean

diffTable

  • diffTable(fromTable: DatabaseTable, toTable: DatabaseTable): false | TableDifference
  • 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

    Returns false | TableDifference

hasSameDefaultValue

  • hasSameDefaultValue(from: Column, to: Column): boolean
  • Parameters

    • from: Column
    • to: Column

    Returns boolean

isIndexFulfilledBy

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


    Parameters

    • index1: Index
    • index2: Index

    Returns boolean