Skip to content

chore(database): move from planetsacle to rds sniff #36

chore(database): move from planetsacle to rds sniff

chore(database): move from planetsacle to rds sniff #36

name: Check database migration
on:
pull_request:
branches:
- 'main'
paths:
- 'packages/domain/prisma/migrations/**'
jobs:
migration-detail:
runs-on: ubuntu-latest
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_PORT: 3306
DATABASE_URL: mysql://root:[email protected]:3306/db
steps:
- uses: actions/checkout@v4
- name: Start MySQL server
run: sudo systemctl start mysql.service
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Run migrations
run: yarn workspace @snipcode/domain db:migrate
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Retrieve and export the production database URL
run: echo "PROD_DATABASE_URL=$(doppler secrets get CONNECTION_STRING --plain)" >> $GITHUB_ENV
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_DATABASE_TOKEN }}
- name: Collect the migration diff
continue-on-error: false
working-directory: packages/domain
run: |
set -e
echo "The following migration will be applied to the production database:" >> migration-message.txt
echo "" >> migration-message.txt
echo "\`\`\`sql" >> migration-message.txt
yarn prisma migrate diff --from-url "$PROD_DATABASE_URL" --to-url "$DATABASE_URL" --script >> migration-message.txt
echo "\`\`\`" >> migration-message.txt
echo "" >> migration-message.txt
echo "" >> migration-message.txt
echo "Please ensure your schema changes are compatible with the application code currently running in production." >> migration-message.txt
- name: Comment pull request with the migration diff
uses: thollander/actions-comment-pull-request@v2
with:
filePath: packages/domain/migration-message.txt