public static function add($typeName, $values, $before = null)
    {
        $values = (array) $values;

        $db = static::getDb();
        if ($db->getTransaction()) {
            // It cannot add a value during a transaction.
            // Start new connection without transactions.
            $db = static::newConnection();
        }

        $query = 'ALTER TYPE ' . $db->quoteColumnName($typeName)
            . ' ADD VALUE IF NOT EXISTS ';

        $beforeQuery = $before !== null
            ? ' BEFORE ' . $db->quoteValue($before)
            : '';

        foreach ($values as $value) {
            $db->createCommand($query . $db->quoteValue($value) . $beforeQuery)->execute();
        }
    }