pyronear / pyro-api

Alert Management API for wildfire prevention, detection & monitoring. Built with FastAPI & PostgreSQL
Apache License 2.0
21 stars 9 forks source link

[db] A CI job to run alembic migrations would be useful #140

Open frgfm opened 3 years ago

frgfm commented 3 years ago

Following up on #112 (more specifically https://github.com/pyronear/pyro-api/pull/112#discussion_r584346620), we need to automate the alembic migration whenever it needs to be run. Depending on the integration, Github Workflow could help with that!

jean-pasquier commented 3 years ago

Just a draft for a new github action, no idea if it works. Questions:

name: dbmigration-alembic
on:
  push:
    branches: master
    paths:
      - 'src/alembic/**'
      - '!src/alembic/README.md'

jobs:
  run-migration:
    runs-on: ubuntu-latest
    needs: install-deps
    defaults:
      run:
        working-directory: src
    steps:
      - uses: actions/checkout@v2
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements-dev.txt
      - name: Run alembic migration
        env:
          DATABASE_URL: ${{ secrets.DATABASE_URL }}
        run: |
          alembic upgrade head
frgfm commented 3 years ago

Thanks a lot for the draft ! Is the paths argument used to limit the event to changes to the files mentioned?

frgfm commented 2 years ago

I think this was fixed by #112, but let me check if everything still works :+1:

ajubin commented 1 year ago

As we're using heroku, what we can do is to perform the migrtation before the app deploy

in Procfile

release: alembic upgrade head # not sure of how to migrate alembic, but it should be something similar

The doc from heroku: https://devcenter.heroku.com/articles/release-phase