Skip to content

Commit 17f8830

Browse files
committed
feat(dump): add includeGeneratedColumns config option and docs" -m "Add CLI flag and config/docs support for including generated/default columns in dumps.
- Add `--include-generated-columns` flag and pass through to dump - Document and example configuration - Adjust table column filtering to include generated columns when enabled - Remove temporary changelog file Signed-off-by: chenen <itfunx@hotmail.com>
1 parent bbfb8cc commit 17f8830

File tree

3 files changed

+27
-76
lines changed

3 files changed

+27
-76
lines changed

CHANGES_GENERATED_COLUMNS.md

Lines changed: 0 additions & 76 deletions
This file was deleted.

docs/configuration.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ The following are the environment variables, CLI flags and configuration file op
7373
| names of databases to exclude from the dump | B | `exclude` | `DB_DUMP_EXCLUDE` | `dump.exclude` | |
7474
| do not include `USE <database>;` statement in the dump | B | `no-database-name` | `DB_DUMP_NO_DATABASE_NAME` | `dump.noDatabaseName` | `false` |
7575
| Replace single long INSERT statement per table with one INSERT statement per line | B | `skip-extended-insert` | `DB_DUMP_SKIP_EXTENDED_INSERT` | `dump.skipExtendedInsert` | `false` |
76+
| Include generated columns in dump (not virtual columns) | B | `include-generated-columns` | `DB_DUMP_INCLUDE_GENERATED_COLUMNS` | `dump.includeGeneratedColumns` | `false` |
7677
| restore to a specific database | R | `restore --database` | `RESTORE_DATABASE` | `restore.database` | |
7778
| how often to do a dump or prune, in minutes | BP | `dump --frequency` | `DB_DUMP_FREQUENCY` | `dump.schedule.frequency` | `1440` (in minutes), i.e. once per day |
7879
| what time to do the first dump or prune | BP | `dump --begin` | `DB_DUMP_BEGIN` | `dump.schedule.begin` | `0`, i.e. immediately |
@@ -139,8 +140,29 @@ for details of each.
139140
* `once`: boolean, run once and exit
140141
* `compression`: string, the compression to use
141142
* `compact`: boolean, compact the dump
143+
* `includeGeneratedColumns`: boolean, include columns marked as `GENERATED` in the dump (does not include `VIRTUAL` columns)
142144
* `triggersAndFunctions`: boolean, include triggers and functions and procedures in the dump
143145
* `maxAllowedPacket`: int, max packet size
146+
147+
When `includeGeneratedColumns` is enabled, columns that are defined with a `GENERATED` attribute or have a default expression
148+
will be included in the row data that is emitted as `INSERT` statements in the dump. Note that `VIRTUAL` columns remain excluded
149+
because they are computed and cannot be restored from dumped values.
150+
151+
Usage example:
152+
153+
Suppose a table has a column defined as:
154+
155+
```sql
156+
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
157+
```
158+
159+
When `includeGeneratedColumns` is turned on, rows for this table will contain the `create_time` value in the `INSERT` statements, e.g.:
160+
161+
```sql
162+
INSERT INTO `mytable` (`id`, `name`, `create_time`) VALUES (1, 'alice', '2025-11-14 09:30:00');
163+
```
164+
165+
This makes the dump include the generated/default timestamp values instead of relying on the default expressions when restoring.
144166
* `filenamePattern`: string, the filename pattern
145167
* `scripts`:
146168
* `preBackup`: string, path to directory with pre-backup scripts

examples/configs/local.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ spec:
2121
safechars: true # defaults to false
2222
noDatabaseName: false # remove the `USE <database>` statement from backup files, defaults to false
2323
skipExtendedInsert: false # replace single long INSERT statement per table with one INSERT statement per line, defaults to false
24+
includeGeneratedColumns: false # include columns marked as GENERATED; VIRTUAL columns remain excluded. Defaults to false
25+
# When enabled, columns with defaults or generated values (for example
26+
# `create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP`) will be
27+
# dumped as part of the INSERT rows. Example:
28+
# INSERT INTO `mytable` (`id`, `name`, `create_time`) VALUES (1, 'alice', '2025-11-14 09:30:00');
2429
# schedule to dump, can use one of: cron, frequency, once. If frequency is set, begin will be checked
2530
schedule:
2631
once: true # run only once and exit; ignores all other scheduling. Defaults to false

0 commit comments

Comments
 (0)