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

feat(migrators): add ternmigrator for jackc/tern #12

Merged
merged 6 commits into from
Sep 25, 2024

Conversation

WillAbides
Copy link
Contributor

@WillAbides WillAbides commented Jul 15, 2024

This PR adds a ternmigrator package for use with jackc/tern. It is based on the patterns established by goosemigrator and bunmigrator, and supports:

  • Using a disk-based or embedded filesystem as the source of migrations.
  • Configuring the name of the table used to keep track of migration state.

This PR closes #10

Copy link
Owner

@peterldowns peterldowns left a comment

Choose a reason for hiding this comment

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

Commenting on WIP. I asked a few questions, but besides the CI failure, this looks fantastic and I'd be OK with merging it. Thanks for the quick turnaround.

@@ -13,8 +13,8 @@ filesystem.
[Golang-defined migrations](https://github.com/pressly/goose#go-migrations) are
not supported by default.

You can configure the migrations directory, the table name, and the filesystem
being used. Here's an example:
[You can configure the migrations directory, the table name, and the filesystem
Copy link
Owner

Choose a reason for hiding this comment

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

Accidental change?

Comment on lines 17 to 26
for _, test := range []struct {
name string
fs fs.FS
}{
{name: "FromDisk"},
{
name: "FromFS",
fs: exampleFS,
},
} {
Copy link
Owner

Choose a reason for hiding this comment

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

Would you mind updating this to follow the pattern of the existing examples, instead of this two-item for loop? Entirely subjective, not a blocker, I would just prefer it that way.

package ternmigrator

import (
"cmp"
Copy link
Owner

Choose a reason for hiding this comment

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

I haven't seen this error before, but can you check the go.mod/go.sum files by running go mod tidy and confirming that the tests pass locally? This may be a CI-only issue, in which case I'll dig in further to figure out how to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cmp was introduced in go1.22. I wasn't thinking about backward compatibility on this part.


var _ pgtestdb.Migrator = (*TernMigrator)(nil)

const defaultTableName = "public.schema_version"
Copy link
Owner

Choose a reason for hiding this comment

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

Why not export this (DefaultTableName)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just because I didn't think about it and I'm generally a minimalist on exports. I exported it in my latest commit.

name: "FromFS",
fs: exampleFS,
},
} {
Copy link
Owner

Choose a reason for hiding this comment

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

Same preference for two separate testcases rather than a two-item for loop. Similarly not a blocker, just a request.

@WillAbides
Copy link
Contributor Author

@peterldowns can you have another look?

@peterldowns peterldowns changed the title Add tern migrator feat(migrators): add ternmigrator for jackc/tern Sep 25, 2024
@peterldowns peterldowns merged commit 92220f2 into peterldowns:main Sep 25, 2024
3 checks passed
@peterldowns
Copy link
Owner

@WillAbides Thank you for your patience — this is great! I only made a few small tweaks to the documentation and git-tagging scripts I use to maintain this repo. Thank you for your contribution!

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.

Add tern migrator
2 participants