Commit 8f06c8b2 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Group category db changes:


- Move upgrade from local to core
- Add fk to groupcategory column of group table
- Rename groupcategory to category to avoid fk naming constraint
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 0547639c
......@@ -271,6 +271,16 @@
<KEY NAME="grouptypefk" TYPE="foreign" FIELDS="grouptype" REFTABLE="grouptype" REFFIELDS="name" />
</KEYS>
</TABLE>
<TABLE NAME="group_category">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="displayorder" TYPE="int" LENGTH="10" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
</KEYS>
</TABLE>
<TABLE NAME="group">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
......@@ -283,11 +293,13 @@
<FIELD NAME="public" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="usersautoadded" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="category" TYPE="int" LENGTH="10" NOTNULL="false" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="nameuk" TYPE="unique" FIELDS="name" />
<KEY NAME="grouptypefk" TYPE="foreign" FIELDS="grouptype" REFTABLE="grouptype" REFFIELDS="name" />
<KEY NAME="categoryfk" TYPE="foreign" FIELDS="category" REFTABLE="group_category" REFFIELDS="id" />
</KEYS>
</TABLE>
<TABLE NAME="group_member">
......
......@@ -1978,5 +1978,23 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2010070700) {
$table = new XMLDBTable('group_category');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('title', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
$table->addFieldInfo('displayorder', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
create_table($table);
$table = new XMLDBTable('group');
$field = new XMLDBField('category');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10);
add_field($table, $field);
$key = new XMLDBKey('categoryfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('category'), 'group_category', array('id'));
add_key($table, $key);
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010062502;
$config->version = 2010070700;
$config->release = '1.3.0beta2dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -7,18 +7,6 @@
defined('INTERNAL') || die();
function xmldb_local_upgrade($oldversion=0) {
if ($oldversion < 1) {
$table = new XMLDBTable('group_category');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('title', XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
$table->addFieldInfo('displayorder', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
create_table($table);
$table = new XMLDBTable('group');
$field = new XMLDBField('groupcategory');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10);
add_field($table, $field);
}
}
?>
\ No newline at end of file
?>
......@@ -6,7 +6,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 1;
$config->version = 0;
$config->release = '0.0.0';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment