Skip to content
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

chore: Handle migration conflicts #9166

Merged
merged 8 commits into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/migration-order.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Migration Order
on:
pull_request:
paths:
- packages/server/postgres/migrations/*.ts
jobs:
migration-order:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3
with:
ref: master

- name: Get newest migration on master
run: |
MAX_OLD_MIGRATION=$(ls packages/server/postgres/migrations | tail -n 1)
echo MAX_OLD_MIGRATION=$MAX_OLD_MIGRATION >> $GITHUB_ENV

- name: Checkout PR
uses: actions/checkout@v3

- name: Get new migrations
id: new-migrations
uses: tj-actions/changed-files@v40
with:
files: packages/server/postgres/migrations/*.ts

- name: Check migration conflicts
run: |
for file in ${{ steps.new-migrations.outputs.added_files }}; do
FILE_NAME=$(basename $file)
if [[ "$FILE_NAME" < "${{ env.MAX_OLD_MIGRATION }}" ]]; then
echo "$FILE_NAME predates ${{ env.MAX_OLD_MIGRATION}}. Please rename it"
exit 1
else
echo "$FILE_NAME does not conflict with existing migrations on master"
fi
done
Loading