You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added a new configuration key include-generated-columns (or environment variable DB_DUMP_INCLUDE_GENERATED_COLUMNS) to allow users to control whether generated columns should be included in database dumps.
# Add Configuration Option to Include Generated Columns
2
+
3
+
## Overview
4
+
Added a new configuration key `include-generated-columns` (or environment variable `DB_DUMP_INCLUDE_GENERATED_COLUMNS`) to allow users to control whether generated columns should be included in database dumps.
5
+
6
+
## Problem
7
+
Previously, the code would always exclude columns marked as `VIRTUAL` or `GENERATED` in the "Extra" field of MySQL's `SHOW COLUMNS` output. This was hardcoded behavior with no way to override it.
8
+
9
+
## Solution
10
+
Implemented a configurable option to control this behavior by:
11
+
12
+
1. Adding a new `IncludeGeneratedColumns` boolean field throughout the configuration chain
13
+
2. Modifying the column filtering logic to respect this setting
14
+
15
+
## Files Modified
16
+
17
+
### 1. `pkg/database/mysql/dump.go`
18
+
- Added `IncludeGeneratedColumns bool` field to the `Data` struct
19
+
- This field controls whether generated columns should be included in dumps
20
+
21
+
### 2. `pkg/database/mysql/table.go`
22
+
- Modified `initColumnData()` function to use `IncludeGeneratedColumns` setting
23
+
-**Before**: Columns with `GENERATED` or `VIRTUAL` were always excluded
24
+
-**After**:
25
+
- Columns with `VIRTUAL` are always excluded (computed columns that can't be stored)
26
+
- Columns with `GENERATED` are excluded UNLESS `IncludeGeneratedColumns` is `true`
27
+
28
+
### 3. `pkg/database/dump.go`
29
+
- Added `IncludeGeneratedColumns bool` to `DumpOpts` struct
30
+
- Updated the `Dump()` function to pass this setting to `mysql.Data`
31
+
32
+
### 4. `pkg/core/dumpoptions.go`
33
+
- Added `IncludeGeneratedColumns bool` to `DumpOptions` struct
34
+
- This carries the setting from CLI/config through to the database layer
35
+
36
+
### 5. `pkg/core/dump.go`
37
+
- Updated `Dump()` function to include `IncludeGeneratedColumns` when creating `database.DumpOpts`
38
+
39
+
### 6. `cmd/dump.go`
40
+
- Added `--include-generated-columns` CLI flag (boolean, defaults to false)
41
+
- Added parsing logic to read the flag value
42
+
- Added `includeGeneratedColumns` variable to the command execution path
0 commit comments