-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: support in-place migration ordering #10614
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2d70e68
update migration docs
robert-zaremba d067a8f
remove todo
robert-zaremba d442004
wip
robert-zaremba d7d2752
proof of concept
robert-zaremba cfe9af7
cleanup
robert-zaremba 20864e6
Use SetOrderMigrations for ordering migrations
robert-zaremba 767a00d
fix
robert-zaremba daa283d
Merge remote-tracking branch 'origin/master' into robert/migration-order
robert-zaremba a55cc22
update module/assertNoForgottenModules
robert-zaremba eb6e147
add tests
robert-zaremba 628ff1f
documentation update
robert-zaremba 2d2752f
adding changelog entry
robert-zaremba b5efc9f
Merge branch 'master' into robert/migration-order
robert-zaremba 607522a
remove SetOrderMigrations from app.go
robert-zaremba 6b21690
Apply suggestions from code review
robert-zaremba ac658c4
update test
robert-zaremba 1eb1f3b
Merge remote-tracking branch 'origin/master' into robert/migration-order
robert-zaremba c2773cb
Merge branch 'master' into robert/migration-order
robert-zaremba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package module | ||
|
||
import ( | ||
"sort" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
func TestModuleIntSuite(t *testing.T) { | ||
suite.Run(t, new(TestSuite)) | ||
} | ||
|
||
type TestSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func (s TestSuite) TestAssertNoForgottenModules() { | ||
m := Manager{ | ||
Modules: map[string]AppModule{"a": nil, "b": nil}, | ||
} | ||
tcs := []struct { | ||
name string | ||
positive bool | ||
modules []string | ||
}{ | ||
{"same modules", true, []string{"a", "b"}}, | ||
{"more modules", true, []string{"a", "b", "c"}}, | ||
} | ||
|
||
for _, tc := range tcs { | ||
if tc.positive { | ||
m.assertNoForgottenModules("x", tc.modules) | ||
} else { | ||
s.Panics(func() { m.assertNoForgottenModules("x", tc.modules) }) | ||
} | ||
} | ||
} | ||
|
||
func (s TestSuite) TestModuleNames() { | ||
m := Manager{ | ||
Modules: map[string]AppModule{"a": nil, "b": nil}, | ||
} | ||
ms := m.ModuleNames() | ||
sort.Strings(ms) | ||
s.Require().Equal([]string{"a", "b"}, ms) | ||
robert-zaremba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
func (s TestSuite) TestDefaultMigrationsOrder() { | ||
require := s.Require() | ||
require.Equal( | ||
[]string{"auth2", "d", "z", "auth"}, | ||
DefaultMigrationsOrder([]string{"d", "auth", "auth2", "z"}), "alphabetical, but auth should be last") | ||
require.Equal( | ||
[]string{"auth2", "d", "z"}, | ||
DefaultMigrationsOrder([]string{"d", "auth2", "z"}), "alphabetical") | ||
} |
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.
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.
the second part was not relevant to this type.
VersionMap
is just a map - it's also use as a return type inRunMigrations