-
Notifications
You must be signed in to change notification settings - Fork 72
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
[POC] Migrating data with foreign key constraints #288
base: main
Are you sure you want to change the base?
Conversation
refer to an issue in ghostferry instead of an internal one
a408db1
to
988e6b2
Compare
logrus.Info("creating databases and tables on target") | ||
for _, tableName := range this.Ferry.Tables.GetTableListWithPriority(this.config.TablesToBeCreatedFirst) { | ||
logger.Info("creating databases and tables on target") | ||
var prioritzedTableNames []string |
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.
var prioritzedTableNames []string | |
var prioritizedTableNames []string |
@@ -342,6 +342,75 @@ func (c TableSchemaCache) GetTableListWithPriority(priorityList []string) (prior | |||
return | |||
} | |||
|
|||
func (c TableSchemaCache) GetTableCreationOrder(db *sql.DB) ([]string, error) { |
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.
Maybe change the name so it doesn't seem like a generic order that people should follow?
func (c TableSchemaCache) GetTableCreationOrder(db *sql.DB) ([]string, error) { | |
func (c TableSchemaCache) GetTableCreationOrderForFKConstraints(db *sql.DB) ([]string, error) { |
|
||
for table := range c { | ||
if _, found := visitedTables[table]; !found { | ||
visitedTables, tableOrder = getTableCreationOrderUtil(visitedTables, tableOrder, tableMap, table) |
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.
Can you document how this algorithm is supposed to work (in either comments attached to a function here, or via a separate document)? It looks feasible to trace through myself, but it's better for a non-trivial algorithm to have its intent documented, so reviewers can focus on if the implementation is right or wrong, not reverse engineering what you're trying to do.
This is an experimental feature in ghostferry to migrate tables with foreign key constraints.
Most of the features are explained in this doc - https://github.com/Shopify/ghostferry/blob/4ea968d2aa702593a4c1ee0f71260333ed88982d/docs/source/copydbforeignkey.rst