Reputation: 2344
I have an old
website and a new
website... the old
website had 4500 orders placed on it, tracked by a table with a primary key for the order id.
When the new
website was launched, it was launched before migrating old
orders into it. To accomplish this, the auto_increment
value on the new
orders table was set to 5000 so any new
order placed would not collide with an old
id.
This allows orders to continue being placed on the new
website, all is well...
Now I'd like to run my import script to bring in the old
orders into the new
website.
Is it possible to temporarily lower the auto_increment
value on the new
orders table to my desired order id?
Disclaimer: This is a migration from a Drupal 5 Ubercart based site, to a Drupal 7 Commerce based site, so I do not (easily) have control over the complex queries involved in assembling the new orders, and cannot simply (AFAIK) supply an order id when assembling an order, because the system always refers to the next available primary key value in the table when creating an order. I can easily take the site offline to run the script, so nothing gets out of sync.
Upvotes: 0
Views: 160
Reputation: 121649
You can always run ALTER TABLE table_name AUTO_INCREMENT = 1;
(or whatever number you want).
The question is: do you WANT to?
If you have any records already in the database, it's probably best to insure the next auto increment value is larger than the maximum already in your database.
Upvotes: 0
Reputation: 2005
For importing the "old" orders you don't need to rely on the autoincrement id-- they already have ids, and you probably want to keep those!
Modify your import script to insert the complete old records into the new table, id and all! As long as the ids don't collide, it shouldn't be a problem.
Upvotes: 3