Documentation
    Preparing search index...

    Class AbstractQueryInterfaceInternal

    The methods in this class are not part of the public API.

    Index
    • Adds a unique index on the column.

      Parameters

      • tableName: TableOrModel

        The table that contains the column

      • columnName: string

        The name of the column, as it is in the database

      • Optionaloptions: QueryRawOptions

        Query options

      Returns Promise<void>

    • Adds a unique constraint on the column, or a unique index if the dialect cannot add constraints to existing tables.

      Parameters

      • tableName: TableOrModel

        The table that contains the column

      • columnName: string

        The name of the column, as it is in the database

      • Optionaloptions: QueryRawOptions

        Query options

      Returns Promise<void>

    • Runs the query that changes the column, then adds a unique key on the column. AbstractQueryInterface#changeColumn uses this in dialects where the ALTER COLUMN query cannot add the unique key (dialect.supports.alterColumn.unique is false).

      Dialects where schema changes are transactional can override this method to do both in one transaction.

      Parameters

      • tableName: TableOrModel

        The table that contains the column

      • columnName: string

        The name of the column, as it is in the database

      • changeColumnSql: string

        The query that changes the column

      • Optionaloptions: QueryRawOptions

        Query options

      Returns Promise<unknown>

    • Parameters

      Returns Promise<unknown>

    • Returns whether the table has a unique key (a unique constraint, a unique index, or the primary key) on exactly the given column.

      Both the unique constraints and the indexes of the table are checked, because depending on the dialect, a unique key can be a unique index without a unique constraint. Snowflake does not report which columns its unique constraints are on, so they are never found there.

      Parameters

      • tableName: TableOrModel

        The table that contains the column

      • columnName: string

        The name of the column, as it is in the database

      • Optionaloptions: QueryRawOptions

        Query options

      Returns Promise<boolean>

    • Returns whether AbstractQueryInterface#changeColumn needs to add a unique key to the column, as requested by its "unique" option. This is only the case if the table does not have a unique key on exactly that column yet, so calling changeColumn again does not add another one.

      Parameters

      • tableName: TableOrModel

        The table that contains the column

      • columnName: string

        The name of the column, as it is in the database

      • unique: AllowArray<string | boolean | { msg?: string; name: string }> | undefined

        The value of the "unique" attribute option

      • Optionaloptions: QueryRawOptions

        Query options

      Returns Promise<boolean>