mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
* Make db waiter to wait latest migration * Move generate out of build * Remove conn require * Allow to ignore migration check * Use shell * Use fail and remote useless log * Generate service-waiter txt when create migration * Revert "Generate service-waiter txt when create migration" This reverts commit 11c12b83544a448f9784f8aa94cdfd69cfb15f45. * Add log
30 lines
923 B
Bash
Executable File
30 lines
923 B
Bash
Executable File
#!/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
|