Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

AUTO_INCREMENT Alter

38 sites No security coverage
View on drupal.org

This module allows you to change the starting ID for database tables in MySQL. This can be useful for preventing ID conflicts, especially when migrating content between Drupal sites.

This module allows altering the AUTO_INCREMENT value of database tables.

One use case is to prevent entity ID conflicts when performing Drupal upgrades.

See https://www.udrupal.com/auto-increment-alter-documentation

REQUIREMENTS

At the moment the module only works with the MySQL driver. The core drupal:mysql module must be enabled.

CONFIGURATION / USAGE

The module provides a auto_increment_alter.mysql service, an admin interface (since alpha 5), and Drush commands offering the following functionality:

* Alter the AUTO_INCREMENT value for a single table.

drush auto-increment-alter:table node 500

* Alter the AUTO_INCREMENT value of multiple tables based on the auto_increment_alter_tables setting.

drush auto-increment-alter:tables

This expects an auto_increment_alter_tables setting containing an associative array of table and value pairs. The keys should be the name of the table to alter. The array values should be integers containing the new AUTO_INCREMENT value. For example:

$settings['auto_increment_alter_tables'] = [
  'node' => 500,
  'node_revision' => 1000,
  'users' => 100,
  'taxonomy_term_data' => 200,
  'taxonomy_term_revision' => 200,
  'file_managed' => 300,
  'media' => 700,
  'media_revision' => 700,
];

* Alter the AUTO_INCREMENT value for a single content entity

drush auto-increment-alter:content-entity node 500 1000
drush auto-increment-alter:content-entity user 100
drush auto-increment-alter:content-entity taxonomy_term 200

The first parameter is the machine name content entity. The second parameter is
the AUTO_INCREMENT value for the base table. The third parameter is the
AUTO_INCREMENT value for the revision table.
If the content entity uses a revision table, but the parameter is not set, the
same value from the base table shall be used. Some content entities do not
make use of revision tables. In those cases, the revision value is ignored even
if set.

* Alter the AUTO_INCREMENT value of content entity tables based on the auto_increment_alter_content_entities setting.

drush auto-increment-alter:content-entities

This expects an auto_increment_alter_content_entities setting containing an associative array of table and value pairs. If a content entity is set, but it does not exist in the current installation it will be filtered out before calling the alter operation. The base and revision tables for the content entity are identified using the entity_type.manager service.

The setting's keys should be the machine name of the content entities. The array values can be set in three ways:

  1. An array with two integer values. The first is used for the base table and the second is used for the revision table.
  2. An array with one integer value. It is used for both the base and revisions tables.
  3. An integer value. It is used for both the base and revisions tables.

Some content entities do not make use of revision tables. In those cases, the revision value is ignored even if set.

$settings['auto_increment_alter_content_entities'] = [
  'node' => [500, 1000],
  'user' => [100],
  'taxonomy_term' => [200],
  'file' => 300,
  'media' => 700,
];

* Get the list of entities, optionally filtered by group.

drush auto-increment-alter:entity-list
drush auto-increment-alter:entity-list --group=content
drush auto-increment-alter:entity-list --group=configuration

* Get the list of tables.

drush auto-increment-alter:table-list

* Get the AUTO_INCREMENT value for a single table.

drush auto-increment-alter:value node

* Get the AUTO_INCREMENT value for all tables.

drush auto-increment-alter:values
drush auto-increment-alter:values --all

This returns table names and their corresponding AUTO_INCREMENT value. If the --all option is provided, the output will include tables that do not
have the AUTO_INCREMENT value set.

See example.settings.auto_increment_alter.php for an example on how to configure the variables used by this module.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
6
Tracked since
Nov 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 6
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
1.0.0-alpha5 Pre-release 10–11 Aug 30, 2025
1.0.0-alpha4 Pre-release 10–11 Jan 25, 2025
1.0.0-alpha3 Pre-release 10–11 Nov 24, 2024
1.0.0-alpha2 Pre-release 10–11 Nov 17, 2024
1.0.0-alpha1 Pre-release 10–11 Nov 10, 2024
1.0.x-dev Dev 10–11 Nov 10, 2024