Skip to content
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

Support multiple PKs during backfilling #426

Merged

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Oct 22, 2024

This PR adds support for using multiple primary keys during the backfilling
part of the migration.

In this PR I extracted the statement builder into a separate struct to
make it easier to check for the expected statements.

@kvch kvch marked this pull request as draft October 22, 2024 14:33
@kvch kvch marked this pull request as ready for review October 25, 2024 10:23
@kvch kvch requested a review from andrew-farries October 25, 2024 10:23
Copy link
Collaborator

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; just a couple of small things.

pkg/migrations/backfill.go Outdated Show resolved Hide resolved
pq.QuoteIdentifier(b.table.Name),
b.batchSize,
whereClause)
return fmt.Sprintf("SELECT %[1]s FROM %[2]s %[3]sORDER BY %[1]s LIMIT %[4]d FOR NO KEY UPDATE",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Sprintf("SELECT %[1]s FROM %[2]s %[3]sORDER BY %[1]s LIMIT %[4]d FOR NO KEY UPDATE",
return fmt.Sprintf("SELECT %[1]s FROM %[2]s %[3]s ORDER BY %[1]s LIMIT %[4]d FOR NO KEY UPDATE",

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record this change adds an extra whitespace when where cluase is missing.

@kvch kvch requested a review from andrew-farries October 29, 2024 12:01
@kvch kvch enabled auto-merge (squash) October 29, 2024 12:01
@kvch kvch merged commit b02c324 into xataio:main Oct 30, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants