summaryrefslogtreecommitdiff
path: root/modules/system/system.install
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.install')
-rw-r--r--modules/system/system.install67
1 files changed, 33 insertions, 34 deletions
diff --git a/modules/system/system.install b/modules/system/system.install
index 97f8e6724..4e5496f90 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -352,23 +352,19 @@ function system_install() {
// Load system theme data appropriately.
system_rebuild_theme_data();
- // Inserting uid 0 here confuses MySQL -- the next user might be created as
- // uid 2 which is not what we want. So we insert the first user here, the
- // anonymous user. uid is 1 here for now, but very soon it will be changed
- // to 0.
db_insert('users')
->fields(array(
+ 'uid' => 0,
'name' => '',
'mail' => '',
))
->execute();
// We need some placeholders here as name and mail are uniques and data is
- // presumed to be a serialized array. Install will change uid 1 immediately
- // anyways. So we insert the superuser here, the uid is 2 here for now, but
- // very soon it will be changed to 1.
-
+ // presumed to be a serialized array. This will be changed by the settings
+ // form.
db_insert('users')
->fields(array(
+ 'uid' => 1,
'name' => 'placeholder-for-uid-1',
'mail' => 'placeholder-for-uid-1',
'created' => REQUEST_TIME,
@@ -376,19 +372,6 @@ function system_install() {
'data' => serialize(array()),
))
->execute();
- // This sets the above two users uid 0 (anonymous). We avoid an explicit 0
- // otherwise MySQL might insert the next auto_increment value.
- db_update('users')
- ->expression('uid', 'uid - uid')
- ->condition('name', '')
- ->execute();
-
- // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem.
- db_update('users')
- ->fields(array('uid' => 1))
- ->condition('name', 'placeholder-for-uid-1')
- ->execute();
-
// Built-in roles.
$rid_anonymous = db_insert('role')
->fields(array('name' => 'anonymous user'))
@@ -615,19 +598,6 @@ function system_schema() {
'primary key' => array('aid'),
);
- $schema['actions_aid'] = array(
- 'description' => 'Stores action IDs for non-default actions.',
- 'fields' => array(
- 'aid' => array(
- 'description' => 'Primary Key: Unique actions ID.',
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array('aid'),
- );
-
$schema['batch'] = array(
'description' => 'Stores details about batches (processes that run in multiple HTTP requests).',
'fields' => array(
@@ -1451,6 +1421,19 @@ function system_schema() {
'primary key' => array('name'),
);
+ $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'),
+ );
+
$schema['sessions'] = array(
'description' => "Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated.",
'fields' => array(
@@ -2866,6 +2849,22 @@ function system_update_7043() {
}
/**
+ * Reuse the actions_aid table as sequences.
+ */
+function system_update_7043() {
+ 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();
+ $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, '<');
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/