Add Configuration Option to Include Generated Columns#485
Open
n2em wants to merge 5 commits intodatabacker:masterfrom
Open
Add Configuration Option to Include Generated Columns#485n2em wants to merge 5 commits intodatabacker:masterfrom
n2em wants to merge 5 commits intodatabacker:masterfrom
Conversation
Collaborator
|
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:
|
Contributor
Author
|
Thanks — really useful review and great guidance. I’ve implemented of your requested repo-side changes and documented |
0b32125 to
c06ca35
Compare
Collaborator
|
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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
Signed-off-by: chenen <[email protected]>
Signed-off-by: chenen <[email protected]>
Collaborator
|
Hi @n2em ; this looks good, just needs the upstream PR in api, and then this can be updated and merged in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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