Commit 17e1cb8a authored by Penny Leach's avatar Penny Leach Committed by Nigel McNie
Browse files

first cut at an upgrade, incomplete but I need to merge

parent 9694f814
......@@ -60,7 +60,7 @@ function artefact_check_plugin_sanity($pluginname) {
foreach ($types as $type) {
$pluginclassname = generate_class_name('blocktype', 'image');
if (get_config('installed')) {
if ($taken = get_record_select('blocktype_installed',
if (table_exists(new XMLDBTable('blocktype_installed')) && $taken = get_record_select('blocktype_installed',
'name = ? AND artefactplugin != ? ',
array($type, $pluginname))) {
throw new InstallationException(get_string('blocktypenametaken', 'error', $type,
......
......@@ -202,6 +202,129 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 20070100200) {
$table = new XMLDBTable('view');
$field = new XMLDBField('template');
drop_field($table, $field);
$table = new XMLDBTable('view_content');
drop_table($table);
$table = new XMLDBTable('template');
drop_table($table);
$table = new XMLDBTable('template_category');
drop_table($table);
$table = new XMLDBTable('view_artefact');
$field = new XMLDBField('ctime');
drop_field($table, $field);
$field = new XMLDBField('format');
drop_field($table, $field);
$table = new XMLDBTable('view_layout');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('columns', XMLDB_TYPE_INTEGER, 1, XMLDB_NOTNULL);
$table->addFieldInfo('widths', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
create_table($table);
$table = new XMLDBTable('view');
$field = new XMLDBField('numcolumns');
$field->setAttributes(XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, null);
add_field($table, $field);
set_field('view', 'numcolumns', 3);
change_field_notnull($table, $field);
$field = new XMLDBField('layout');
$field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, null);
add_field($table, $field);
$key = new XMLDBKEY('layoutfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('layout'), 'view_layout', array('id'));
add_key($table, $key);
// plugin contract tables for new blocktype plugin type.
$table = new XMLDBTable('blocktype_category');
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, 50, XMLDB_NOTNULL);
$table->addkeyInfo('primary', XMLDB_KEY_PRIMARY, array('name'));
create_table($table);
//function addFieldInfo($name, $type, $precision=null, $unsigned=null, $notnull=null, $sequence=null, $enum=null, $enumvalues=null, $default=null, $previous=null) {
$table = new XMLDBTable('blocktype_installed');
$table->addFieldInfo('version', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addFieldInfo('name', XMLDB_TYPE_CHAR, 10, XMLDB_NOTNULL);
$table->addFieldInfo('active', XMLDB_TYPE_INTEGER, 1, XMLDB_NOTNULL, null, null, null, 1);
$table->addFieldInfo('artefactplugin', XMLDB_TYPE_CHAR, 255, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('name'));
create_table($table);
$table = new XMLDBTable('blocktype_cron');
$table->addFieldInfo('plugin', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addFieldInfo('callfunction', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addFieldInfo('minute', XMLDB_TYPE_CHAR, 25, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('hour', XMLDB_TYPE_CHAR, 25, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('day', XMLDB_TYPE_CHAR, 25, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('weekofmonth', XMLDB_TYPE_CHAR, 25, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('year', XMLDB_TYPE_CHAR, 25, XMLDB_NOTNULL, null, null, null, '*');
$table->addFieldInfo('nextrun', XMLDB_TYPE_DATETIME, null, null);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('plugin', 'callfunction'));
$table->addKeyInfo('pluginfk', XMLDB_TYPE_FOREIGN, array('plugin'), 'blocktype_installed', array('name'));
create_table($table);
$table = new XMLDBTable('blocktype_config');
$table->addFieldInfo('plugin', XMLDB_TYPE_CHAR, 100, XMLDB_NOTNULL);
$table->addFieldInfo('field', XMLDB_TYPE_CHAR, 100, XMLDB_NOTNULL);
$table->addFieldInfo('value', XMLDB_TYPE_TEXT, 'small', XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('plugin', 'field'));
$table->addKeyInfo('pluginfk', XMLDB_TYPE_FOREIGN, array('plugin'), 'blocktype_installed', array('name'));
create_table($table);
$table = new XMLDBTable('blocktype_event_subscription');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('plugin', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addFieldInfo('event', XMLDB_TYPE_CHAR, 50, XMLDB_NOTNULL);
$table->addFieldInfo('callfunction', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('pluginfk', XMLDB_KEY_FOREIGN, array('plugin'), 'blocktype_installed', array('name'));
$table->addKeyInfo('eventfk', XMLDB_KEY_FOREIGN, array('event'), 'event_type', array('name'));
$table->addKeyInfo('subscruk', XMLDB_KEY_UNIQUE, array('plugin', 'event', 'callfunction'));
create_table($table);
$table = new XMLDBTable('blocktype_installed_category');
$table->addFieldInfo('blocktype', XMLDB_TYPE_CHAR, 50, XMLDB_NOTNULL);
$table->addFieldInfo('category', XMLDB_TYPE_CHAR, 50, XMLDB_NOTNULL);
$table->addKeyInfo('blocktypefk', XMLDB_KEY_FOREIGN, array('blocktype'), 'blocktype_installed', array('name'));
$table->addKeyInfo('categoryfk', XMLDB_KEY_FOREIGN, array('category'), 'blocktype_category', array('name'));
create_table($table);
$table = new XMLDBTable('block_instance');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED,
XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('blocktype', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addFieldInfo('title', XMLDB_TYPE_CHAR, 255, XMLDB_NOTNULL);
$table->addFieldInfo('configdata', XMLDB_TYPE_TEXT, null);
$table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, XMLDB_NOTNULL);
$table->addFIeldInfo('column', XMLDB_TYPE_INTEGER, 2, XMLDB_NOTNULL);
$table->addFIeldInfo('order', XMLDB_TYPE_INTEGER, 2, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->addKeyInfo('blocktypefk', XMLDB_KEY_FOREIGN, array('blocktype'), 'blocktype_installed', array('name'));
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
$table->addKeyInfo('viewcolumnorderuk', XMLDB_KEY_UNIQUE, array('view', 'column', 'order'));
create_table($table);
}
return $status;
}
......
......@@ -163,7 +163,8 @@ function check_upgrades($name=null) {
// definitely fail
$pluginversion = 0;
if (!$installing) {
if ($installed = get_record($plugintype . '_installed', 'name', $pluginname)) {
if (table_exists(new XMLDBTable($plugintype . '_installed'))
&& $installed = get_record($plugintype . '_installed', 'name', $pluginname)) {
$pluginversion = $installed->version;
$pluginrelease = $installed->release;
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007082201;
$config->version = 2007100020;
$config->release = '0.9.0dev';
$config->minupgradefrom = 2007080700;
$config->minupgraderelease = '0.8.0 (release tag 0.8.0_RELEASE)';
......
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