Comment to 'Messenger error'
Comment to Messenger error
  • Hello @Romulus !

    Could you reupload the DB error screenshot? As we don't see the wrong points in the query like:

    DELETE FROM `sys_objects_uploader` WHERE `object` = 'bx_messenger_html5';
    
    • Another error generated by the notification module in this file line 20 https://github.com/unacms/una/blob/master/modules/boonex/notifications/install/sql/enable.sql a comment in sql

      SET @iPBOrderDashboard = 4; --(SELECT IFNULL(MAX(`order`), 0) FROM `sys_pages_blocks` WHERE `object` = 'sys_dashboard' AND `cell_id` = @iPBCellDashboard LIMIT 1);
      
      

      Another error is in these sql files from the notifications module due by the , comment added in sintax. Here the comment needs one more space after the two dashes.

      SET @iPBOrderDashboard = 4; -- (SELECT IFNULL(MAX(`order`), 0) FROM `sys_pages_blocks` WHERE `object` = 'sys_dashboard' AND `cell_id` = @iPBCellDashboard LIMIT 1);
      
      

      I found a lot of sql files that are not compliant

      • if you have doubts about how to make a comment, check the documentation https://dev.mysql.com/doc/refman/8.4/en/comments.html

        • From a --  sequence to the end of the line. In MySQL, the --  (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on). This syntax differs slightly from standard SQL comment syntax, as discussed in Section 1.7.2.4, “'--' as the Start of a Comment”.
        mysql> SELECT 1+1;     # This comment continues to the end of line
        mysql> SELECT 1+1;     -- This comment continues to the end of line
        mysql> SELECT 1 /* this is an in-line comment */ + 1;
        mysql> SELECT 1+
        /*
        this is a
        multiple-line comment
        */
        1;
        
        • another example, uninstalling the notification mode gives me another error:

          SET @sName = 'bx_notifications';
          
          
          
          DROP TABLE IF EXISTS `bx_notifications_events`, `bx_notifications_events2users`, `bx_notifications_read`;
          DROP TABLE IF EXISTS `bx_notifications_handlers`, `bx_notifications_settings`, `bx_notifications_settings2users`;
          DROP TABLE IF EXISTS `bx_notifications_queue`;
          
          
          
          -- STUDIO PAGE & WIDGET
          DELETE FROM `tp`, `tw`, `twb`, `tpw` 
          USING `sys_std_pages` AS `tp` LEFT JOIN `sys_std_widgets` AS `tw` ON `tp`.`id` = `tw`.`page_id` LEFT JOIN `sys_std_widgets_bookmarks` AS `twb` ON `tw`.`id` = `twb`.`widget_id` LEFT JOIN `sys_std_pages_widgets` AS `tpw` ON `tw`.`id` = `tpw`.`widget_id`
          WHERE  `tp`.`name` = @sName;
          
          
          

          Only after modifying the uninstall.sql file did I manage to uninstall the module.

          In your SQL script, the issue arises with the `DELETE` command used to remove records from the `sys_std_pages`, `sys_std_widgets`, `sys_std_widgets_bookmarks`, and `sys_std_pages_widgets` tables. In MySQL, the `DELETE ... USING` syntax is not supported as it is in other SQL databases. Instead, MySQL requires a different approach to delete records that are related through JOINs.

          Here's how you can correct the SQL command:

          Correcting the `DELETE` Command

          1. Delete Data from Dependent Tables:

            - First, delete records from the dependent tables (i.e., tables that have `FOREIGN KEY` references to the primary tables).

          2. Delete Data from Primary Tables:

            - After deleting data from the dependent tables, you can then delete data from the primary tables.

          Here’s how you can rephrase the SQL command to delete data from the respective tables:

          SET @sName = 'bx_notifications';
          -- Delete data from dependent tables
          DELETE `tpw` FROM `sys_std_pages_widgets` AS `tpw`
          JOIN `sys_std_widgets` AS `tw` ON `tpw`.`widget_id` = `tw`.`id`
          JOIN `sys_std_widgets_bookmarks` AS `twb` ON `tw`.`id` = `twb`.`widget_id`
          JOIN `sys_std_pages` AS `tp` ON `tp`.`id` = `tw`.`page_id`
          WHERE `tp`.`name` = @sName;
          DELETE `twb` FROM `sys_std_widgets_bookmarks` AS `twb`
          JOIN `sys_std_widgets` AS `tw` ON `twb`.`widget_id` = `tw`.`id`
          JOIN `sys_std_pages` AS `tp` ON `tp`.`id` = `tw`.`page_id`
          WHERE `tp`.`name` = @sName;
          DELETE `tw` FROM `sys_std_widgets` AS `tw`
          JOIN `sys_std_pages` AS `tp` ON `tp`.`id` = `tw`.`page_id`
          WHERE `tp`.`name` = @sName;
          DELETE `tp` FROM `sys_std_pages` AS `tp`
          WHERE `tp`.`name` = @sName;
          

          Explanation

          - First `DELETE`: Removes records from `sys_std_pages_widgets` (tpw) that are associated with widgets and pages where `name` equals `@sName`.

          - Second `DELETE`: Removes records from `sys_std_widgets_bookmarks` (twb) that are associated with widgets with `page_id` in the specified page.

          - Third `DELETE`: Removes records from `sys_std_widgets` (tw) that have `page_id` in the specified page.

          - Fourth `DELETE`**: Removes records from `sys_std_pages` (tp) where `name` equals `@sName`.

          This approach ensures that all records are deleted according to the relationships between the tables and prevents issues with references.

          Make sure to take a complete backup of the database before running these commands, as data deletion is irreversible.