fix(ci): skip applied migrations in preflight validation
TaxBaik CI/CD / build-and-deploy (push) Has been cancelled
TaxBaik CI/CD / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -47,10 +47,24 @@ if ! command -v psql >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mapfile -t executed_versions < <(
|
||||
psql "$DB_CONNECTION_STRING" -Atc "SELECT version FROM schema_migrations ORDER BY version;" 2>/dev/null || true
|
||||
)
|
||||
|
||||
declare -A executed_map=()
|
||||
for version in "${executed_versions[@]}"; do
|
||||
if [ -n "$version" ]; then
|
||||
executed_map["$version"]=1
|
||||
fi
|
||||
done
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
name="$(basename "$file")"
|
||||
version="${name#V}"
|
||||
version="${version%%__*}"
|
||||
if [ -n "${executed_map[$version]:-}" ]; then
|
||||
continue
|
||||
fi
|
||||
echo "Dry-run migration V$version: $name"
|
||||
psql "$DB_CONNECTION_STRING" -v ON_ERROR_STOP=1 <<PSQL
|
||||
BEGIN;
|
||||
|
||||
Reference in New Issue
Block a user