How tho fix error on migration



  • Hi. on vapor
    I use Vapor for bagisto deplyment and when I run artisan migrate after migrating half of migration I confront with this error on Vapor :
    ``Migrating: 2019_11_21_194608_add_stored_function_to_get_url_path_of_category
    [2023-03-01 16:09:28] production.ERROR: SQLSTATE[HY000]: General error: 1419 You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable) (SQL: DROP FUNCTION IF EXISTS get_url_path_of_category;
    CREATE FUNCTION get_url_path_of_category(
    categoryId INT,
    localeCode VARCHAR(255)
    )
    RETURNS VARCHAR(255)
    DETERMINISTIC
    BEGIN

                DECLARE urlPath VARCHAR(255);
                -- Category with id 1 is root by default
                IF categoryId <> 1
                THEN
                    SELECT
                        GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO urlPath
                    FROM
                        categories AS node,
                        categories AS parent
                        JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id
                    WHERE
                        node._lft >= parent._lft
                        AND node._rgt <= parent._rgt
                        AND node.id = categoryId
                        AND parent.id <> 1
                        AND parent_translations.locale = localeCode
                    GROUP BY
                        node.id;
    
                    IF urlPath IS NULL
                    THEN
                        SET urlPath = (SELECT slug FROM category_translations WHERE category_translations.category_id = categoryId);
                    END IF;
                 ELSE
                    SET urlPath = '';
                 END IF;
    
                 RETURN urlPath;
            END;) {"exception":"[object] (Illuminate\\Database\\QueryException(code: HY000): SQLSTATE[HY000]: General error: 1419 You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) (SQL:             DROP FUNCTION IF EXISTS `get_url_path_of_category`;
            CREATE FUNCTION get_url_path_of_category(
                categoryId INT,
                localeCode VARCHAR(255)
            )
            RETURNS VARCHAR(255)
            DETERMINISTIC
            BEGIN
    
                DECLARE urlPath VARCHAR(255);
                -- Category with id 1 is root by default
                IF categoryId <> 1
                THEN
                    SELECT
                        GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO urlPath
                    FROM
                        categories AS node,
                        categories AS parent
                        JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id
                    WHERE
                        node._lft >= parent._lft
                        AND node._rgt <= parent._rgt
                        AND node.id = categoryId
                        AND parent.id <> 1
                        AND parent_translations.locale = localeCode
                    GROUP BY
                        node.id;
    
                    IF urlPath IS NULL
                    THEN
                        SET urlPath = (SELECT slug FROM category_translations WHERE category_translations.category_id = categoryId);
                    END IF;
                 ELSE
                    SET urlPath = '';
                 END IF;
    
                 RETURN urlPath;
            END;)`
    

    could you help me to fix it on Vapor actually I fixed this issue by running '--log_bin_trust_function_creators=1' command , but in Vapor I can not run it . 😞



  • Hi there,

    Please run the below command.

    mysql -u USERNAME -p
    set global log_bin_trust_function_creators=1;
    

Log in to reply