Salesforce sync redesign #2554
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
| name: Migrations | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| - 'db/migrate/**' | |
| - 'db/schema.rb' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| migrations: | |
| timeout-minutes: 15 | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:11 | |
| ports: | |
| - 5432:5432 | |
| options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| bundler-cache: true | |
| # Load the base branch schema to simulate an existing production database | |
| - name: Load base schema | |
| env: | |
| OXA_DB_USER: postgres | |
| OXA_DB_PASS: postgres | |
| RAILS_ENV: test | |
| run: | | |
| git show origin/${{ github.base_ref }}:db/schema.rb > db/schema_base.rb | |
| cp db/schema_base.rb db/schema.rb | |
| bin/rake db:create db:schema:load | |
| git checkout -- db/schema.rb | |
| # Run only the new migrations from this PR | |
| - name: Run migrations | |
| env: | |
| OXA_DB_USER: postgres | |
| OXA_DB_PASS: postgres | |
| RAILS_ENV: test | |
| run: bin/rake db:migrate | |
| # Verify the resulting schema matches what's committed | |
| - name: Verify schema | |
| run: | | |
| if ! git diff --exit-code db/schema.rb; then | |
| echo "❌ db/schema.rb is out of date. Run migrations locally and commit the updated schema." | |
| exit 1 | |
| fi | |
| echo "✅ Schema is up to date" |