Skip to content

Commit

Permalink
build(database): target the pr branch when applying migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
tericcabrel committed Jun 23, 2024
1 parent 49a3789 commit e51afb0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/migration-db-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,30 @@ on:
- 'main'
paths:
- 'packages/domain/prisma/migrations/**'
pull_request:
branches:
- 'main'

env:
PLANETSCALE_SERVICE_TOKEN_ID: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_ID }}
PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }}

jobs:
print-branch-name:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Print pull request branch
if: github.event_name == 'pull_request'
run: |
echo "Pull Request Branch: ${{ github.event.pull_request.head.ref }}"
apply-migration:
# run only the push event on the main branch
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -22,9 +39,9 @@ jobs:
- name: Set database branch name
run: |
echo "Name 1: ${{ github.ref }}"
echo "Name 2: ${{ github.head_ref }}"
echo "Name 3: ${{ github.base_ref }}"
echo "Name 4: ${{ github.event.pull_request }}"
echo "Name 2: ${{ github.ref_name }}"
echo "Name 3: ${{ github.ref_type }}"
echo "Name 4: ${{ github }}"
echo "PSCALE_BRANCH_NAME=$(echo ${{ github.event.pull_request.base.ref }} | tr -cd '[:alnum:]-'| tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Get the deploy request number in development branch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
Warnings:
- You are about to drop the column `is_favorite` on the `folders` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX `folders_is_favorite_idx` ON `folders`;
Expand Down

0 comments on commit e51afb0

Please sign in to comment.