Repository navigation
[Build] Check the schema steps on every pull request #2113
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
yili-db
merged 17 commits into
unitycatalog:main
from
shba24:stack/uc-upgrade-merge-checks
Nov 13, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c70c490
[Build] Check the schema steps on every pull request
shba24 76ea533
[Build] Tighten the schema step rules after review
shba24 6d7c5d1
[Build] Check effect files and fixed inputs through one column check
shba24 659f7f4
[Build] Simplify the enum member check and correct the index rule doc
shba24 0159c18
[Build] Catch unbounded numeric and dropped MySQL defaults in the ste…
shba24 37ba0ad
[Build] Refuse a later-step index on a text column too long to index
shba24 779528a
[Build] Size the whole index key, and refuse types the rule can't bound
shba24 a4f5da3
[Build] Count the index entry's headers in the key-size rule
shba24 c1e1e27
[Build] Run the schema step checks in the all-tests rows
shba24 c77fd19
[Build] Close the index-size and enum gaps Yi found in the step rules
shba24 79620ca
[Build] Refuse a later-step partial index
shba24 e33ad77
[Build] Let updateSchemaDumps write the effect files of several new s…
shba24 070da79
[Build] Read a PostgreSQL negative numeric scale as negative in the s…
shba24 e1f8cac
[Build] Allow only literal defaults, and re-size an index whose colum…
shba24 8de2526
[Build] Say why the schema step check failed, and record steps with t…
shba24 431a23e
[Build] Re-size an index only when a column's type, size or scale cha…
shba24 a395b2c
[Build] Move the domain reviewer's Flyway line to its own PR
shba24 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
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,76 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Fails when HEAD edits, deletes or renames a schema migration step, or a step's effect file, that | ||
| # exists on <base-ref>. Databases already ran those steps, and the effect files tell | ||
| # --upgrade-schema what they did, so a change to the schema must be a new step. | ||
| # Fails when a new step's version is not above every step on <base-ref> for that database: | ||
| # databases already past it would never run it (Flyway refuses such a step). | ||
| # Also fails on any new step when <base-branch> is a release branch (branch-*): the step's number | ||
| # could clash with a different step on main, and the next upgrade would break. | ||
| # | ||
| # Usage: dev/check-migration-steps.sh <base-ref> [<base-branch>] | ||
| # Needs the history back to the merge base of <base-ref> and HEAD (CI passes HEAD^1, the merge | ||
| # commit's first parent, so fetch-depth: 2 is enough). CI passes the pull request's base branch | ||
| # name as <base-branch>. | ||
|
|
||
| set -euo pipefail | ||
|
shba24 marked this conversation as resolved.
Resolved
|
||
| # The paths below are relative to the repository root. | ||
| cd "$(git rev-parse --show-toplevel)" | ||
|
|
||
| if [[ $# -lt 1 || $# -gt 2 ]]; then | ||
| echo "Usage: $0 <base-ref> [<base-branch>]" >&2 | ||
| exit 2 | ||
| fi | ||
| base_branch=${2:-} | ||
|
|
||
| steps_dir=server/src/main/resources/db/migration | ||
| effects_dir=server/src/main/resources/schema-effects | ||
|
|
||
| if ! merge_base=$(git merge-base "$1" HEAD); then | ||
| echo "No merge base between $1 and HEAD; fetch more history." >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| changed=$(git diff --diff-filter=MDRT --name-status "$merge_base" HEAD -- "$steps_dir" "$effects_dir") | ||
| if [[ -n "$changed" ]]; then | ||
| echo "These merged migration steps or effect files changed since $1:" >&2 | ||
| echo "$changed" >&2 | ||
| echo "Merged steps can't change; add a new step under $steps_dir/<db>/ instead." >&2 | ||
| exit 1 | ||
| fi | ||
| echo "No merged migration step or effect file changed since $1." | ||
|
|
||
| # A release branch takes no new steps at all, so say that before checking their numbers. | ||
| added=$(git diff --diff-filter=A --name-only "$merge_base" HEAD -- "$steps_dir" "$effects_dir") | ||
| if [[ -n "$added" && "$base_branch" == branch-* ]]; then | ||
| echo "These migration steps are new on the release branch $base_branch:" >&2 | ||
| echo "$added" >&2 | ||
| echo "Release branches take no new steps; add the step on main." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # The version of a step file name V<version>__<description>.sql. | ||
| version_of() { basename "$1" | sed -n 's/^V\([0-9]*\)__.*/\1/p'; } | ||
|
|
||
| added_steps=$(git diff --diff-filter=A --name-only "$merge_base" HEAD -- "$steps_dir") | ||
| for step in $added_steps; do | ||
| folder=$(dirname "$step") | ||
| highest=$(git ls-tree --name-only "$1" -- "$folder/" \ | ||
| | while read -r f; do version_of "$f"; done | sort -n | tail -n 1) | ||
| version=$(version_of "$step") | ||
| if [[ ! "$version" =~ ^[0-9]+$ ]]; then | ||
| echo "The new step $step has a version that is not a whole number." >&2 | ||
| echo "Name it V<number>__<description>.sql." >&2 | ||
| exit 1 | ||
| fi | ||
| # 10# keeps bash from reading a leading zero (V08) as octal. | ||
| version=$((10#$version)) | ||
| if [[ -n "$highest" ]]; then | ||
| highest=$((10#$highest)) | ||
| fi | ||
| if [[ -n "$highest" && "$version" -le "$highest" ]]; then | ||
| echo "The new step $step is not above step $highest, the highest on $1." >&2 | ||
| echo "Renumber it above every merged step." >&2 | ||
|
shba24 marked this conversation as resolved.
Resolved
|
||
| exit 1 | ||
| fi | ||
| done | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.