Moodle

Any field operation (drop, rename, change_xxx) must look for field dependencies (indexes, keys...)

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Database:
    Any
  • Difficulty:
    Moderate
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

As explained in http://moodle.org/mod/forum/discuss.php?d=127196 current behaviour when trying to perform field ddl actions (drop field, rename, change some property...) is really not cross-db at all, with each DB following different approaches.

So, in order to get a consistent approach for any DB we are going to:

1) Create one new ddl_dependency_exception (extends ddl_change_structure_exception)
2) In dbmanager, perform the required dependency checks (mainly look for existing indexes for now) and throw that exception if dependency is found.
3) In XMLDB editor, when generating PHP code to be used in upgrade scripts, look for the XMLDB definition (not to DB!) and if there is any dependency, include php code to drop/create indexes.

Issue Links

Activity

Hide
Tim Hunt added a comment -

Sounds good to me.

Show
Tim Hunt added a comment - Sounds good to me.
Hide
Eloy Lafuente (stronk7) added a comment -

0) Review 1.9 => 2.0 upgrade, looking for dependencies and fixing them before commit the checker.

Show
Eloy Lafuente (stronk7) added a comment - 0) Review 1.9 => 2.0 upgrade, looking for dependencies and fixing them before commit the checker.
Hide
Eloy Lafuente (stronk7) added a comment -

Done:

0) reviewed upgrade only 2 fields being dropped needed the extra check of related indexes.
1) ddl exception defined
2) ddl exception thrown. Only when dropping columns for now.

TODO:

3) Make the XMLDB Editor to generate PHP code able to drop / recreate related indexes.

Show
Eloy Lafuente (stronk7) added a comment - Done: 0) reviewed upgrade only 2 fields being dropped needed the extra check of related indexes. 1) ddl exception defined 2) ddl exception thrown. Only when dropping columns for now. TODO: 3) Make the XMLDB Editor to generate PHP code able to drop / recreate related indexes.
Hide
Eloy Lafuente (stronk7) added a comment -

Resolving as fixed, 3) will happen in MDL-19701 (part of the XMLDB Editor Meta bug).

Show
Eloy Lafuente (stronk7) added a comment - Resolving as fixed, 3) will happen in MDL-19701 (part of the XMLDB Editor Meta bug).
Hide
Eloy Lafuente (stronk7) added a comment -

Reviewed upgrade script, going to enforce the dependencies on every alter column operation.

Show
Eloy Lafuente (stronk7) added a comment - Reviewed upgrade script, going to enforce the dependencies on every alter column operation.
Hide
Eloy Lafuente (stronk7) added a comment -

Now looking for dependencies is enforced in every database manager change_field_xxx() method.

TODO: Make the XMLDB Editor to generate PHP code able to drop / recreate related indexes (MDL-19701)

Show
Eloy Lafuente (stronk7) added a comment - Now looking for dependencies is enforced in every database manager change_field_xxx() method. TODO: Make the XMLDB Editor to generate PHP code able to drop / recreate related indexes (MDL-19701)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: