Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(infra): derive the import-data table count from the importers

Yudhi Armyndharis4265ad66afb5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ce9b6e97..26afe4f33 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A session whose automatic reconnect fails to relaunch the engine (a network, DNS or browser launch error) keeps retrying with backoff instead of stopping in `failed` until restarted by hand; an authentication failure or a stale browser profile still ends in `failed` ([#1580](https://github.com/rmyndharis/OpenWA/issues/1580)).
- A session that runs out of reconnect attempts fires the `session:error` plugin hook when it lands in `failed`.
- An explicit `maxReconnectAttempts` is honoured and the reconnect delay is capped at 5 minutes; the budget used to restart once the backoff passed 5 minutes, so the limit was never reached and the documented 1-hour cap never applied.
+- Restoring a PostgreSQL backup into SQLite stores creation and update timestamps in SQLite's own format, so restored pending webhook deliveries and ingress events are replayed on the day they were created instead of from the next UTC day.
+- The `POST /api/infra/import-data` schema and the API docs state 16 migration tables, including the `chatStates` and `webhookOutboxEvents` keys the restore already clears.
## [0.23.5] - 2026-09-14
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.md
index 2f1f435ac..efa557396 100644
--- a/docs/06-api-specification.md
+++ b/docs/06-api-specification.md
@@ -5444,7 +5444,7 @@ Request a graceful server restart, optionally orchestrating Docker profiles (add
#### GET /api/infra/export-data
-Export every row of the 14 migration tables from the Data DB as JSON. Read-only, but runs raw `SELECT *` on the `data` DataSource.
+Export every row of the 16 migration tables from the Data DB as JSON. Read-only, but runs raw `SELECT *` on the `data` DataSource.
**Auth:** API key (ADMIN)
@@ -5454,7 +5454,7 @@ Export every row of the 14 migration tables from the Data DB as JSON. Read-only,
>
> This bounds the media, not the export — a large enough text-only history still exceeds the import limit, because every row costs a few hundred bytes of scaffolding whatever was said. For a backup that keeps everything, use `scripts/backup.sh`: it snapshots the database file itself (and `pg_dump`s Postgres), so inline media rides along regardless of this budget.
-The migration set (`MigrationTables`) is, in payload-key order: `sessions`, `webhooks`, `messages`, `messageBatches`, `templates`, `baileysStoredMessages`, `lidMappings`, `pluginInstances`, `conversationMappings`, `ingressEvents`, `webhookDeliveryFailures`, `integrationDeliveryFailures`, `statusUpdates`, `automationRules`.
+The migration set (`MigrationTables`) is, in payload-key order: `sessions`, `webhooks`, `messages`, `messageBatches`, `templates`, `baileysStoredMessages`, `lidMappings`, `chatStates`, `pluginInstances`, `conversationMappings`, `ingressEvents`, `webhookDeliveryFailures`, `webhookOutboxEvents`, `integrationDeliveryFailures`, `statusUpdates`, `automationRules`.
**Response** `200`
@@ -5525,7 +5525,7 @@ Rows are raw DB column shapes (e.g. `messageBatches` rows use snake_case columns
Replace all Data DB rows with the supplied export. **Destructive and transactional (all-or-nothing).**
-> **The replace covers all 14 migration tables, not just the ones you send.** Inside the transaction every table in the migration set is emptied first and only then re-populated from the payload, so a table you omit ends up **empty**, not untouched. Always restore a payload produced by `GET /api/infra/export-data` of the same or a newer build — a hand-built body carrying only a subset silently wipes the rest.
+> **The replace covers all 16 migration tables, not just the ones you send.** Inside the transaction every table in the migration set is emptied first and only then re-populated from the payload, so a table you omit ends up **empty**, not untouched. Always restore a payload produced by `GET /api/infra/export-data` of the same or a newer build — a hand-built body carrying only a subset silently wipes the rest.
**Auth:** API key (ADMIN)
diff --git a/docs/07-api-collection.md b/docs/07-api-collection.md
index c3135190f..cf3d49ca3 100644
--- a/docs/07-api-collection.md
+++ b/docs/07-api-collection.md
@@ -1457,7 +1457,7 @@ curl "$BASE/api/infra/export-data" \
#### POST /api/infra/import-data
-Replace all Data DB rows with a prior export (destructive, all-or-nothing). Every one of the 14 migration tables is emptied first, so a key you omit restores **empty** rather than untouched — send a body produced by `GET /api/infra/export-data`, not a hand-built subset. All 14 keys are shown below for that reason.
+Replace all Data DB rows with a prior export (destructive, all-or-nothing). Every one of the 16 migration tables is emptied first, so a key you omit restores **empty** rather than untouched — send a body produced by `GET /api/infra/export-data`, not a hand-built subset. All 16 keys are shown below for that reason.
```bash
curl -X POST "$BASE/api/infra/import-data" \
@@ -1467,8 +1467,9 @@ curl -X POST "$BASE/api/infra/import-data" \
"tables": {
"sessions": [ { "id": "s1", "name": "main", "status": "ready", "phone": "15551234567", "pushName": "Me", "config": {}, "proxyUrl": null, "proxyType": null, "connectedAt": "2026-06-25T00:00:00.000Z", "lastActiveAt": "2026-06-25T00:00:00.000Z", "createdAt": "2026-06-25T00:00:00.000Z", "updatedAt": "2026-06-25T00:00:00.000Z" } ],
"webhooks": [], "messages": [], "messageBatches": [], "templates": [], "baileysStoredMessages": [],
- "lidMappings": [], "pluginInstances": [], "conversationMappings": [], "ingressEvents": [],
- "webhookDeliveryFailures": [], "integrationDeliveryFailures": [], "statusUpdates": [], "automationRules": []
+ "lidMappings": [], "chatStates": [], "pluginInstances": [], "conversationMappings": [], "ingressEvents": [],
+ "webhookDeliveryFailures": [], "webhookOutboxEvents": [], "integrationDeliveryFailures": [], "statusUpdates": [],
+ "automationRules": []
}
}'
```
diff --git a/docs/14-migration-guide.md b/docs/14-migration-guide.md
index 4e78bb1d3..6d4facc3c 100644
--- a/docs/14-migration-guide.md
+++ b/docs/14-migration-guide.md
@@ -114,7 +114,7 @@ curl -X POST 'http://localhost:2785/api/infra/import-data' \
```
> [!IMPORTANT]
-> Post the whole exported file, as the `-d @data-backup.json` above does. The import empties all 14
+> Post the whole exported file, as the `-d @data-backup.json` above does. The import empties all 16
> migration tables before repopulating, so a hand-built body carrying only some keys restores the rest
> **empty**. The export also bounds the inline media it carries
> (`EXPORT_INLINE_MEDIA_BUDGET_BYTES`, 8 MiB by default); for a byte-exact copy including media, use
diff --git a/openapi.json b/openapi.json
index 6e61545c8..404d3d564 100644
--- a/openapi.json
+++ b/openapi.json
@@ -14181,7 +14181,7 @@
"properties": {
"tables": {
"type": "object",
- "description": "Every one of the 14 migration tables is emptied before the restore runs, so a key omitted here is restored EMPTY rather than left untouched. Post the whole GET /api/infra/export-data payload, not a hand-built subset.",
+ "description": "Every one of the 16 migration tables is emptied before the restore runs, so a key omitted here is restored EMPTY rather than left untouched. Post the whole GET /api/infra/export-data payload, not a hand-built subset.",
"properties": {
"sessions": {
"type": "array"
diff --git a/src/modules/infra/dto/import-data.dto.spec.ts b/src/modules/infra/dto/import-data.dto.spec.ts
index ba3be457b..9a58a8a5f 100644
--- a/src/modules/infra/dto/import-data.dto.spec.ts
+++ b/src/modules/infra/dto/import-data.dto.spec.ts
@@ -54,6 +54,14 @@ function exportEnvelope(): Record<string, unknown> {
}
describe('ImportDataDto', () => {
+ it('publishes the table count the restore actually clears', () => {
+ const snapshot = JSON.parse(readFileSync(join(__dirname, '..', '..', '..', '..', 'openapi.json'), 'utf8')) as {
+ components: { schemas: Record<string, { properties: Record<string, { description?: string }> }> };
+ };
+ const description = snapshot.components.schemas.ImportDataDto.properties.tables.description;
+ expect(description).toContain(`Every one of the ${TABLE_IMPORTERS.length} migration tables`);
+ });
+
it('rejects a body with no tables, naming the field', async () => {
const { errors } = await run({ force: true });
// Before this DTO the inline `@Body()` type erased, so this body reached the restore and threw
diff --git a/src/modules/infra/dto/import-data.dto.ts b/src/modules/infra/dto/import-data.dto.ts
index a333603a5..0d0404e24 100644
--- a/src/modules/infra/dto/import-data.dto.ts
+++ b/src/modules/infra/dto/import-data.dto.ts
@@ -19,7 +19,7 @@ const TABLE_PROPERTIES: Record<string, { type: 'array' }> = Object.fromEntries(
* route in the product a body carrying no `tables` reached the handler and failed as a 500 from
* inside the restore, and a misspelled key was accepted in silence.
*
- * `tables` is validated as an object and not descended into: without @ValidateNested the fourteen
+ * `tables` is validated as an object and not descended into: without @ValidateNested the per-table
* row arrays are leaf values, so whitelist cannot strip them. That is load-bearing, not incidental —
* every key omitted here is restored EMPTY, so a whitelist that reached inside would silently blank
* the database it was asked to restore.
@@ -42,8 +42,7 @@ const TABLE_PROPERTIES: Record<string, { type: 'array' }> = Object.fromEntries(
export class ImportDataDto {
@ApiProperty({
type: 'object',
- description:
- 'Every one of the 14 migration tables is emptied before the restore runs, so a key omitted here is restored EMPTY rather than left untouched. Post the whole GET /api/infra/export-data payload, not a hand-built subset.',
+ description: `Every one of the ${TABLE_IMPORTERS.length} migration tables is emptied before the restore runs, so a key omitted here is restored EMPTY rather than left untouched. Post the whole GET /api/infra/export-data payload, not a hand-built subset.`,
properties: TABLE_PROPERTIES,
})
@IsObject()