Skip to content
database

GitHub Action

Migrate database

v0.2.1 Latest version

Migrate database

database

Migrate database

Database seed tool built with golang-migrate

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Migrate database

uses: VoVaVc/[email protected]

Learn more about this action in VoVaVc/migrate-github-action

Choose a version

Migrate for GitHub Actions

A wrapper for golang-migrate cli.

Input variables

See action.yml for more detailed information.

  • path - relative path to your migration folder
  • database - a command to connect to the database
  • command - migrate cli command to run
  • prefetch - Number of migrations to load in advance before executing (default 10)
  • lockTimeout - Allow N seconds to acquire database lock (default 15)
  • verbose - Print verbose logging
  • version - Print version

Migrate CLI docs

Usage with postgres

name: run migration
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
        name: Checkout
        uses: actions/checkout@v3
      - name: Migrate
        uses: vovavc/[email protected]
        with:
            path: ./backend/migrate
            database: postgres://username:password@localhost:5432/database_name?sslmode=disable
            command: up

Usage with mysql and github secrets

name: run migration
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
        name: Checkout
        uses: actions/checkout@v3
      - name: Migrate
        uses: vovavc/[email protected]
        with:
            path: ./backend/migrate
            database: mysql://${{ secrets.DB_USER }}:${{ secrets.DB_PASS }}@tcp(${{ secrets.DB_HOST }})/${{ secrets.DB_NAME }}?tls=${{ secrets.DB_TLS }}
            command: up

Contributing

Pull requests are welcome at VoVaVc/migrate-github-action

License

The scripts and documentation in this project are released under the MIT License