-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make db waiter to wait latest migration #18455
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9db0a6d
Make db waiter to wait latest migration
mustard-mh ef7ca68
Move generate out of build
mustard-mh 9589785
Remove conn require
mustard-mh 972d185
Allow to ignore migration check
mustard-mh c904117
Use shell
mustard-mh cd4b0cf
Use fail and remote useless log
mustard-mh 11c12b8
Generate service-waiter txt when create migration
mustard-mh 6408fa4
Revert "Generate service-waiter txt when create migration"
mustard-mh 2ca5179
Add log
mustard-mh 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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
# Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
# Licensed under the GNU Affero General Public License (AGPL). | ||
# See License.AGPL.txt in the project root for license information. | ||
|
||
get_latest_migration() { | ||
# List all migrations and sort | ||
migrations=$(find ./src/typeorm/migration/*.ts | sort -n | sed 's/\.\/src\/typeorm\/migration\///g' | sed 's/\.ts//g') | ||
|
||
# Get the latest migration and format its name {ts}-{name} into {name}{ts} | ||
# To align to the generated TypeORM class name which used as migration name | ||
latest_migration=$(echo "$migrations" | tail -n 1 | sed 's/\([0-9]\{13\}\)-\(.*\)/\2\1/g') | ||
|
||
# Echo the latest migration | ||
echo "$latest_migration" | ||
} | ||
|
||
test() { | ||
if [ -z "$(get_latest_migration)" ]; then | ||
echo "Error: get_latest_migration() should not be empty" 1>&2; | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [ "$1" == "test" ]; then | ||
test | ||
else | ||
get_latest_migration | ||
fi |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) 2023 Gitpod GmbH. All rights reserved. | ||
// Licensed under the GNU Affero General Public License (AGPL). | ||
// See License.AGPL.txt in the project root for license information. | ||
|
||
package cmd | ||
|
||
import ( | ||
_ "embed" | ||
"os" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestGetLatestMigrationName(t *testing.T) { | ||
t.Run("should have latest migration name", func(t *testing.T) { | ||
path, err := os.Getwd() | ||
if err != nil { | ||
t.Errorf("failed to get current work dir: %v", err) | ||
return | ||
} | ||
if !strings.Contains(path, "components-service-waiter--app") { | ||
t.Skip("skipping test; not running in leeway build") | ||
return | ||
} | ||
if GetLatestMigrationName() == "" { | ||
t.Errorf("migration name should not be empty") | ||
} | ||
}) | ||
} |
Empty file.
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
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.