Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-21116

When uninstalling a block the tables in install.xml should be dropped in reverse order

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.5
    • 2.0
    • Database SQL/XMLDB
    • None
    • MySQL 5.1.33

      I have foreign key constraints defined in an install.xml script for a block I am developing.

      When $foreign_keys=true in sql_generator.php this block is correctly installed, along with it's constraints, because the tables are ordered such that any table with a foreign key constraint is installed after the table it is dependant upon.

      However, when I uninstall that block the tables are dropped in the same order they were installed, which causes database errors resulting in some tables being left behind after the block is deleted.

      e.g. "Cannot delete or update a parent row: a foreign key constraint fails"

      As a general policy does it not make more sense for the uninstall function to drop tables from an install.xml script in the reverse order to which they are declared (i.e. drop the last table first and the first table last)?

            skodak Petr Skoda
            evan.irving-pease Evan Irving-Pease
            Dan Poltawski Dan Poltawski
            Adrian Greeve Adrian Greeve
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.