summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-20 19:06:09 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-10-20 19:06:09 +0000
commitee7bd3ceab7f46a99c0e4390ec06669d405d1c1a (patch)
treea50a50818717fc7b338a8652fff4f44749c938bd /modules
parent8f21cc40259db9406e00a083b4b6ca2ff9ebbb57 (diff)
downloadbrdo-ee7bd3ceab7f46a99c0e4390ec06669d405d1c1a.tar.gz
brdo-ee7bd3ceab7f46a99c0e4390ec06669d405d1c1a.tar.bz2
#356074 follow-up by mfb: Fix sequences API upgrade path.
Diffstat (limited to 'modules')
-rw-r--r--modules/system/system.install25
1 files changed, 16 insertions, 9 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index a3eb618d2..87dfb8d1f 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -2859,16 +2859,23 @@ function system_update_7043() {
* Reuse the actions_aid table as sequences.
*/
function system_update_7044() {
- db_drop_primary_key('actions_aid');
- db_change_field('actions_aid', 'aid', 'value', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('value')));
- db_rename_table('actions_aid', 'sequences');
- $max = db_query('SELECT MAX(value) FROM {sequences}')->fetchField();
+ $schema['sequences'] = array(
+ 'description' => 'Stores IDs.',
+ 'fields' => array(
+ 'value' => array(
+ 'description' => 'The value of the sequence.',
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ ),
+ ),
+ 'primary key' => array('value'),
+ );
+ db_create_table('sequences', $schema['sequences']);
+ $max_aid = db_query('SELECT MAX(aid) FROM {actions_aid}')->fetchField();
$max_uid = db_query('SELECT MAX(uid) FROM {users}')->fetchField();
- if ($max_uid > $max) {
- db_update('sequences')->fields(array('value' => $max_uid))->execute();
- }
- $max = db_query('SELECT MAX(value) FROM {sequences}')->fetchField();
- db_delete('sequences')->condition('value', $max, '<');
+ db_insert('sequences')->fields(array('value' => max($max_aid, $max_uid)))->execute();
+ db_drop_table('actions_aid');
}
/**