-
Notifications
You must be signed in to change notification settings - Fork 209
Add Configuration Option to Include Generated Columns #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Wow, that is one comprehensive PR comment. This looks good in principle, happy to include it as an option. There are a few change you need to make:
|
deitch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment
|
Thanks — really useful review and great guidance. I’ve implemented of your requested repo-side changes and documented |
0b32125 to
c06ca35
Compare
|
This looks good so far. All it needs now is upstream in databacker/api to include it as an option, merge that in, and then include that here and reference it. |
…ment variable `DB_DUMP_INCLUDE_GENERATED_COLUMNS`) to allow users to control whether generated columns should be included in database dumps. Signed-off-by: chenen <itfunx@hotmail.com>
…ment variable `DB_DUMP_INCLUDE_GENERATED_COLUMNS`) to allow users to control whether generated columns should be included in database dumps. Signed-off-by: chenen <itfunx@hotmail.com>
…dd 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>
Signed-off-by: chenen <itfunx@hotmail.com>
Signed-off-by: chenen <itfunx@hotmail.com>
Add Configuration Option to Include Generated Columns
Overview
Added a new configuration key
include-generated-columns(or environment variableDB_DUMP_INCLUDE_GENERATED_COLUMNS) to allow users to control whether generated columns should be included in database dumps.Problem
Previously, the code would always exclude columns marked as
VIRTUALorGENERATEDin the "Extra" field of MySQL'sSHOW COLUMNSoutput. This was hardcoded behavior with no way to override it.Solution
Implemented a configurable option to control this behavior by:
IncludeGeneratedColumnsboolean field throughout the configuration chainFiles Modified
1.
pkg/database/mysql/dump.goIncludeGeneratedColumns boolfield to theDatastruct2.
pkg/database/mysql/table.goinitColumnData()function to useIncludeGeneratedColumnssettingGENERATEDorVIRTUALwere always excludedVIRTUALare always excluded (computed columns that can't be stored)GENERATEDare excluded UNLESSIncludeGeneratedColumnsistrue3.
pkg/database/dump.goIncludeGeneratedColumns booltoDumpOptsstructDump()function to pass this setting tomysql.Data4.
pkg/core/dumpoptions.goIncludeGeneratedColumns booltoDumpOptionsstruct5.
pkg/core/dump.goDump()function to includeIncludeGeneratedColumnswhen creatingdatabase.DumpOpts6.
cmd/dump.go--include-generated-columnsCLI flag (boolean, defaults to false)includeGeneratedColumnsvariable to the command execution pathcore.DumpOptionsstructUsage
Command Line
Default Behavior
By default (
--include-generated-columnsis not set), the behavior is unchanged:VIRTUALcolumns are excludedGENERATEDcolumns are excludedWith the Flag
When
--include-generated-columnsis set:VIRTUALcolumns are still excluded (they cannot be restored)GENERATEDcolumns are included in the dumpEnvironment Variable
The setting can also be controlled via environment variable:
DB_DUMP_INCLUDE_GENERATED_COLUMNStrueorfalseexport DB_DUMP_INCLUDE_GENERATED_COLUMNS=trueNotes
api.Dumptype in the databacker/api repositoryVIRTUALcolumns are always excluded as they cannot be dumped and restored