Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@haog1
Last active January 20, 2018 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haog1/598cf2cf42da4ee711a12355ab772618 to your computer and use it in GitHub Desktop.
Save haog1/598cf2cf42da4ee711a12355ab772618 to your computer and use it in GitHub Desktop.
Why auto_increment not set to be 1 (Not finish)

Database auto increment number

This will briefly discuss the issue about that should set the database auto increment to 1 or other number.

According to the official doc from ClearDB, it says this:

ClearDB uses circular replication to provide master-master MySQL support. As such, certain things such as auto_increment keys (or sequences) must be configured in order for one master not to use the same key as the other, in all cases. We do this by configuring MySQL to skip certain keys, and by enforcing MySQL to use a specific offset for each key used. The reason why we use a value of 10 instead of 2 is for future development.

So they set the auto_increment gap to 10 in purpose, which means that It is not allowed to set auto_increment to 1 unless specifing the keys by hard-coding.

Therefore, just running SET @@auto_increment_increment=1 would not work as normal.

So the right solution to solve the gap is to accept the existing rules. While this might sound a bit hush on those who insists on using 1 for auto_increment, however it is the default rules for using ClearDB

Solution

What I did to solve this solution is to add another tag which is not using auto_increment, such like name,'entity_slug' to replace with using id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment