chore(database): move from planetsacle to rds sniff #25
Workflow file for this run
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
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 | |
run: curl -Ls https://cli.doppler.com/install.sh | sh | |
- 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 | |
if: ${{ env.DEPLOY_REQUEST_OPENED }} | |
run: | | |
echo "The following migration will be applied to the production database:" > migration-message.txt | |
echo "" >> migration-message.txt | |
echo "\`\`\`sql" >> migration-message.txt | |
echo "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: migration-message.txt |