Issue Details (XML | Word | Printable)

Key: MDL-19695
Type: Sub-task Sub-task
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Eloy Lafuente (stronk7)
Reporter: Eloy Lafuente (stronk7)
Votes: 0
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-14679

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

Created: 02/Jul/09 09:29 PM   Updated: 31/Jul/09 02:56 AM
Component/s: Database SQL/XMLDB
Affects Version/s: 2.0
Fix Version/s: 2.0

Issue Links:
Dependency
 

Database: Any
Participants: Eloy Lafuente (stronk7) and Tim Hunt
Security Level: None
Difficulty: Moderate
Resolved date: 03/Jul/09
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
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.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Tim Hunt added a comment - 02/Jul/09 09:32 PM
Sounds good to me.

Eloy Lafuente (stronk7) added a comment - 02/Jul/09 10:58 PM
0) Review 1.9 => 2.0 upgrade, looking for dependencies and fixing them before commit the checker.

Eloy Lafuente (stronk7) added a comment - 03/Jul/09 12:11 AM
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.


Eloy Lafuente (stronk7) added a comment - 03/Jul/09 12:35 AM
Resolving as fixed, 3) will happen in MDL-19701 (part of the XMLDB Editor Meta bug).

Eloy Lafuente (stronk7) added a comment - 31/Jul/09 02:49 AM
Reviewed upgrade script, going to enforce the dependencies on every alter column operation.

Eloy Lafuente (stronk7) added a comment - 31/Jul/09 02:56 AM
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)