2006/5/11, Adrian Rossouw <adrian@bryght.com>:
Now that we have .install files for modules, I believe it is time we
extended our database abstraction layer.
True, it should be sufficient to define a table structure only once in the install file.
I recommend we create the following extra functions :
1. db_create_table($tablename, $columns); // columns is an
associative array with the 'name' => 'type'
3. db_drop_table($tablename);
3. db_create_index($tablename, $columns); // columns is an array of
column names, or just a single column.
4. db_drop_index($tablename, $columns);
5. db_add_column($tablename, $column, $type); // PGSQL already has a
similar function, but it isn't in both systems.
6. db_drop_column($tablename, $column);
These functions are a useful addition, but I am not sure if the developer that defines tables for his module should need to use them. An alternative for the install system could be that the structure of the tables is defined in a xml file that can be validated before it is processed by the install system.
Kind regards,
John Pulles
http://mappingwidgets.sourceforge.net | carto module