code: protected function findTableConstraints($table, $type)
      {
          $keyColumnUsageTableName = 'INFORMATION_SCHEMA.KEY_COLUMN_USAGE';
          $tableConstraintsTableName = 'INFORMATION_SCHEMA.TABLE_CONSTRAINTS';
          if ($table->catalogName !== null) {
              $keyColumnUsageTableName = $table->catalogName . '.' . $keyColumnUsageTableName;
              $tableConstraintsTableName = $table->catalogName . '.' . $tableConstraintsTableName;
          }
          $keyColumnUsageTableName = $this->quoteTableName($keyColumnUsageTableName);
          $tableConstraintsTableName = $this->quoteTableName($tableConstraintsTableName);
  
          $sql = <<<SQL
  SELECT
      [kcu].[constraint_name] AS [index_name],
      [kcu].[column_name] AS [field_name]
  FROM {$keyColumnUsageTableName} AS [kcu]
  LEFT JOIN {$tableConstraintsTableName} AS [tc] ON
      [kcu].[table_schema] = [tc].[table_schema] AND
      [kcu].[table_name] = [tc].[table_name] AND
      [kcu].[constraint_name] = [tc].[constraint_name]
  WHERE
      [tc].[constraint_type] = :type AND
      [kcu].[table_name] = :tableName AND
      [kcu].[table_schema] = :schemaName
  SQL;
  
          return $this->db
              ->createCommand($sql, [
                  ':tableName' => $table->name,
                  ':schemaName' => $table->schemaName,
                  ':type' => $type,
              ])
              ->queryAll();
      }
docs: Collects the constraint details for the given table and constraint type.
  @param TableSchema $table
  @param string $type either PRIMARY KEY or UNIQUE
  @return array each entry contains index_name and field_name
  @since 2.0.4