Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 72793ad

Browse files
authored
Merge pull request #5129 from magento/db_kb_conversion
Converting the Change Increment ID KB to devdocs
2 parents afab7a2 + 0b63b1f commit 72793ad

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

_data/toc/configuration-guide.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ pages:
275275
url: /config-guide/multi-site/ms_over.html
276276
children:
277277

278+
- label: Change increment ID for a database entity on particular store
279+
url: /config-guide/multi-site/change-increment-id.html
280+
278281
- label: Set up multiple websites, stores, and store views in the Admin
279282
url: /config-guide/multi-site/ms_websites.html
280283

@@ -423,4 +426,4 @@ pages:
423426
url: /architecture/gdpr/magento-2x.html
424427

425428
- label: Magento 1.x
426-
url: /architecture/gdpr/magento-1x.html
429+
url: /architecture/gdpr/magento-1x.html
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
group: configuration-guide
3+
title: Change increment ID for a database entity on particular store
4+
functional_areas:
5+
- Configuration
6+
- System
7+
- Setup
8+
---
9+
10+
This article discusses how to change the increment ID for a Magento database (DB) entity (order, invoice, credit memo, etc.) on a particular Magento store using the `ALTER TABLE` SQL statement.
11+
12+
## Affected versions
13+
14+
- {{site.data.var.ee}} (on premise): 2.x.x
15+
- {{site.data.var.ece}}: 2.x.x
16+
- MySQL: [any supported version][]
17+
18+
## When would you need to change increment ID
19+
20+
You might need to change the increment ID for new DB entities in these cases:
21+
22+
- After a hard backup restore on a Live site
23+
- Some order records have been lost, but their IDs are already being used by payment gateways (like PayPal) for your current Merchant account. Such being the case, the payment gateways stop processing new orders that have the same IDs, returning the "Duplicate invoice id" error
24+
25+
{: .bs-callout-info}
26+
You may also fix the payment gateway issue for PayPal by allowing multiple payments per invoice ID in PayPal's Payment Receiving Preferences. See [PayPal gateway rejected request - duplicate invoice issue][] in the _Knowledge Base_.
27+
28+
## Prerequisite steps
29+
30+
1. Find stores and entities for which the new increment ID should be changed.
31+
1. Connect to your MySQL DB.
32+
For {{site.data.var.ece}}, at first, you need to connect using SSH to your environment.
33+
1. Check the current `auto_increment` value for the entity sequence table using the following query:
34+
35+
```sql
36+
SHOW TABLE STATUS FROM `{database_name}` WHERE `name` LIKE 'sequence_{entity_type}_{store_id}';
37+
```
38+
39+
If you are checking an auto increment for an order on the store with ID=1, the table name would be 'sequence_order_1'.
40+
41+
If the value of the `auto_increment` column is '1234', the next order placed at the store with `ID=1` will have the ID '#100001234'.
42+
43+
## Update entity to change increment ID
44+
45+
Update the entity using the following query:
46+
47+
```sql
48+
ALTER TABLE sequence_{entity_type}_{store_id} AUTO_INCREMENT = {new_increment_value};
49+
```
50+
51+
{: .bs-callout-info}
52+
Important: The new increment value must be greater than the current one.
53+
54+
After executing the following query:
55+
56+
```sql
57+
ALTER TABLE sequence_order_1 AUTO_INCREMENT = 2000;
58+
```
59+
60+
The next order placed at the store with `ID=1` will have the ID '#100002000'.
61+
62+
## Additional recommended steps on cloud production environments
63+
64+
Before executing the `ALTER TABLE` query on a production environment of {{site.data.var.ece}}, we strongly recommend performing these steps:
65+
66+
- Test the entire procedure of changing the increment ID on your staging environment
67+
- [Create a DB backup][] to restore your Production DB in case of failure
68+
69+
## Related documentation
70+
71+
- [Set up a remote MySQL database connection][]
72+
- [Create database dump on Cloud][]
73+
- [SSH to your environment][]
74+
75+
<!-- Link Definitions -->
76+
[PayPal gateway rejected request - duplicate invoice issue]: https://support.magento.com/hc/en-us/articles/115002457473
77+
[Set up a remote MySQL database connection]: {{ page.baseurl }}/install-gde/prereq/mysql_remote.html
78+
[Create a DB backup]: https://support.magento.com/hc/en-us/articles/360003254334
79+
[Create database dump on Cloud]: https://support.magento.com/hc/en-us/articles/360003254334
80+
[SSH to your environment]: {{ page.baseurl }}/cloud/env/environments-ssh.html#ssh
81+
[any supported version]: {{ page.baseurl }}/install-gde/prereq/mysql.html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../v2.2/config-guide/multi-site/change-increment-id.md

0 commit comments

Comments
 (0)