-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test adding a test_field for versioned migration changes (#12)
- Loading branch information
1 parent
e426869
commit 8e4f1e4
Showing
15 changed files
with
283 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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,62 @@ | ||
name: Database schema migration check | ||
on: | ||
# Run whenever code is changed in the main branch, | ||
push: | ||
branches: | ||
- main | ||
# Run on PRs where something changed under the `ent/migrate/migrations/` directory. | ||
pull_request: | ||
paths: | ||
- 'ent/**' | ||
jobs: | ||
migration-check: | ||
services: | ||
# Spin up a postgres:10 container to be used as the dev-database for analysis. | ||
postgres: | ||
image: postgres:10 | ||
env: | ||
POSTGRES_DB: test | ||
POSTGRES_PASSWORD: pass | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
fetch-depth: 0 # Mandatory unless "latest" is set below. | ||
|
||
# doesn't seem to work - does not recognize migrations files. | ||
# - uses: ariga/[email protected] | ||
# with: | ||
# dir: ent/migrate/migrations | ||
# dir-format: golang-migrate # Or: atlas, goose, dbmate | ||
# dev-url: postgres://postgres:pass@localhost:5432/test?sslmode=disable | ||
|
||
- name: Check for migration changes | ||
id: check_migrations | ||
run: | | ||
# List files changed in the PR | ||
echo "Checking for changes between ${{ github.event.pull_request.base.sha }} and ${{ github.sha }}" | ||
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) | ||
echo "Changed files: $changed_files" | ||
# Check for changes in 'ent/schema' | ||
schema_changes=$(echo "$changed_files" | grep '^ent/schema' || true) | ||
echo "Schema changes: $schema_changes" | ||
# Check for changes in 'ent/migrate/migrations' | ||
migration_changes=$(echo "$changed_files" | grep '^ent/migrate/migrations' || true) | ||
echo "Migration changes: $migration_changes" | ||
# If there are schema changes but no migration changes, fail the check | ||
if [ -n "$schema_changes" ] && [ -z "$migration_changes" ]; then | ||
echo "::error::Changes in 'ent/schema' require corresponding changes in 'ent/migrate/migrations'" | ||
exit 1 | ||
else | ||
echo "Check passed: Schema changes are accompanied by migration changes." | ||
fi |
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: semgrep | ||
name: Logging check | ||
on: | ||
push: | ||
branches: | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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 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,2 @@ | ||
-- Modify "nodes" table | ||
ALTER TABLE "nodes" ADD COLUMN "test_field" text NOT NULL; |
This file contains 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
h1:N8EzSLepKv1NCdsdGortcG5sDpeTVBxeIo5ANvXdktU= | ||
h1:qDiQeVaeKVjOjw5Yv9X/s3l4bU33dQ3QstZ/g8MJky0= | ||
20240526144817_migration.sql h1:sP6keX+oMyLL2qpIFx0Ns0WYfWM5hJ4zkFPmLWT68fM= | ||
20240528220411_migration.sql h1:MWbTfx95zDNhc3BL0B4bSC959NKyxzLYGHxreKO9D2M= |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.