Changing starting order number?

I recreated my store from UC to Commerce and i think the last thing I need to do is start the order numbers at a specific number. I couldn't get the migration to work so I just opted for a complete rebuild. But now I have no orders. Not a big problem if I can manage this task.


Posted: Nov 17, 2011


Prince Manfred on November 17, 2011

WARNING: I've never done this. It might end the world or explode your database server. It might break Commerce or Drupal or both and make you cry.

However, what if you ran the SQL query "ALTER TABLE commerce_order AUTO_INCREMENT = 1000;" That might do the trick. Heck, now I'm curious. I'm gonna go try it right now : ).


If you backup your database before doing this you won't have to worry so much :)

scottrouse on November 23, 2011

Just wanted to chime in and say that, as far as I can tell, this works fine. One thing to note is that, if you have items in a cart before doing this with a certain user account or browser session and complete checkout after changing the auto_increment, that order will be completed with its original, lower order number since the order # is assigned once items are placed in a cart. Any new orders, however, will have the new higher number.

Prince Manfred on November 17, 2011

Fantastic. It looks like it works. If you have a database prefix you're using for your Drupal install you'll probably have to stick that in front of "commerce_order" in that query. I haven't tested this at all beyond seeing that the next order I created was order 1000. I can't imagine anything being broken by this but who knows.

(Change 1000 to whatever you want the next order to be)

Sean on November 17, 2011

I will give it a try a little later and report back. Don't worry, I do backup the database. :D