Moodle
  1. Moodle
  2. MDL-20437

When I set $foreign_keys=true in in sql_generator.php, the ddl is not created.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.5
    • Fix Version/s: None
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Database:
      MySQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Rank:
      5575

      Description

      It seems that , $foreign_keys = true in sql_generator.php, foreign keys are defined on each table immediately after the table is created, even if the referenced table has not yet been created. To get the foreign keys, I changed sql_generator.php to create all the foreign keys only after creating all of the tables. A diff is attached.

        Issue Links

          Activity

          Hide
          Bruce Cota added a comment -

          Uhh.. my patch doesn't work, I shouldn't have uploaded. it. I have one that does work, but I find many tables in which a foreign key column (like mdl_config_log.userid , etc) seem to have a convention of using a "0" in place of a "null", so I'm not sure if I should pursue this.

          Show
          Bruce Cota added a comment - Uhh.. my patch doesn't work, I shouldn't have uploaded. it. I have one that does work, but I find many tables in which a foreign key column (like mdl_config_log.userid , etc) seem to have a convention of using a "0" in place of a "null", so I'm not sure if I should pursue this.
          Hide
          Evan Irving-Pease added a comment -

          Rather than delaying creation of foreign key constraints, would this not be better fixed by correctly ordering the various tables in the install scripts, such that tables containing foreign key constraints are installed after the tables they are dependant on?

          Show
          Evan Irving-Pease added a comment - Rather than delaying creation of foreign key constraints, would this not be better fixed by correctly ordering the various tables in the install scripts, such that tables containing foreign key constraints are installed after the tables they are dependant on?
          Hide
          Michael de Raadt added a comment -

          Thanks for reporting this issue.

          We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

          If you believe that this issue is still relevant to current versions (2.3 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

          Michael d;

          4d6f6f646c6521

          Show
          Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.3 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; 4d6f6f646c6521
          Hide
          Michael de Raadt added a comment -

          I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported.

          If you still believe this is an issue in supported versions, please report a new issue.

          Show
          Michael de Raadt added a comment - I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you still believe this is an issue in supported versions, please report a new issue.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: