--- uc_tablequote.install 2009-03-31 19:41:44.000000000 +0100 +++ uc_tablequote.fix.install 2010-03-15 15:47:14.812500000 +0000 @@ -34,15 +34,102 @@ function uc_tablequote_schema() { ), 'primary key' => array('qid'), ); + $schema['uc_tablequote_methods'] = array( + 'description' => t('List of distinct methods for uc_tablequote'), + 'fields' => array( + 'qmid' => array( + 'type' => 'serial', + 'not null' => TRUE + ), + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '' + ), + 'weight' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0 + ), + 'quote_mode' => array( + 'type' => 'varchar', + 'not null' => TRUE, + 'default' => 'weight', + 'length' => 15 + ), + 'label' => array( + 'type' => 'varchar', + 'not null' => TRUE, + 'default' => '', + 'length' => 255 + ), + ), + 'primary key' => array('qmid'), + ); return $schema; } function uc_tablequote_install() { drupal_install_schema('uc_tablequote'); + db_add_field($ret, 'uc_tablequote', 'qmid', array('type' => 'int', 'not null' => TRUE)); } function uc_tablequote_uninstall(){ // Remove tables. drupal_uninstall_schema('uc_tablequote'); + db_drop_field($ret, 'uc_tablequote', 'qmid'); } + +/* +* I have moved the functionality from here to hook_install, but left this orphaned function for people to run manually if they are updating a previous install +*/ +function uc_tablequote_update_1() { + $schema['uc_tablequote_methods'] = array( + 'description' => t('List of distinct methods for uc_tablequote'), + 'fields' => array( + 'qmid' => array( + 'type' => 'serial', + 'not null' => TRUE + ), + 'title' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '' + ), + 'weight' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0 + ), + 'quote_mode' => array( + 'type' => 'varchar', + 'not null' => TRUE, + 'default' => 'weight', + 'length' => 15 + ), + 'label' => array( + 'type' => 'varchar', + 'not null' => TRUE, + 'default' => '', + 'length' => 255 + ), + ), + 'primary key' => array('qmid'), + ); + + $ret = array(); + db_create_table($ret, 'uc_tablequote_methods', $schema['uc_tablequote_methods']); + + db_query('INSERT INTO {uc_tablequote_methods} (title, label, quote_mode, weight) VALUES ("%s", "%s", "%s", 0)', t('Default'), t('Default'), variable_get('uc_tablequote_type','weight')); + $qmid = db_last_insert_id('uc_tablequote_methods', 'qmid'); + + $ret = array(); + db_add_field($ret, 'uc_tablequote', 'qmid', array('type' => 'int', 'not null' => TRUE)); + db_query('UPDATE {uc_tablequote} SET qmid = %d', $qmid); + + return $ret; +} +