Dropping DB fields expected behaviour

Dropping DB fields expected behaviour

by Eloy Lafuente (stronk7) -
Number of replies: 4
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi,

Imagine one table, T, with two fields, A and B, with one index on them (I).

Right now, if we try to drop the T->A field, this happens:

- MySQL: The index is "magically" transformed to index B only (crazy, imagine if the index is an unique one!)
- PG: The index is dropped automatically (acceptable)
- Oracle: The index is dropped automatically (acceptable)
- MSSQL: The operation is forbidden. Index must be dropped first (consistent)

Obviously, that isn't cross-db at all. And I guess this behaviour will affect also other functions like those changing field specs.

The question is, in order to get one homogeneous behaviour in our DB API... which approach should we follow:

1) Prevent any modification in one field if there are indexes on it. Throw exception if such "dependencies" are found.
2) Automatically drop (dependent) indexes.

My personal vote goes to 1 (prevent and throw exception). But wanted to hear from you... ciao smile
Average of ratings: -
In reply to Eloy Lafuente (stronk7)

Re: Dropping DB fields expected behaviour

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
1. is OK by me.

We will give you bonus points if you can make XMLDB automatically generate the right PHP code for all cases.