Public | Automated Build

Last pushed: 4 days ago
Short Description
Dockerized flyway command-line tool with options for updated mariadb driver or added mysql driver
Full Description

Docker Flyway

Dockerized flyway command-line tool with options
to use:

  • MariaDB Connector/J driver version other than the one that ships with flyway
  • MySQL Connector/J driver instead of MariaDB Connector/J driver for jdbc:mysql: connections

Supported tags and respective Dockerfile links

Getting started

docker run dhoer/flyway [flyway cli arguments here]

Example

Add a file named V1__Initial.sql with following contents:

CREATE TABLE MyTable (
    MyColumn VARCHAR(100) NOT NULL
);

Linux

docker run --rm -v $(pwd):/flyway/sql dhoer/flyway -url=jdbc:mysql://mydb -schemas=myschema -user=root -password=P@ssw0rd migrate

Windows 10 (Docker for Windows)

CMD:

docker run --rm -v %cd%:/flyway/sql dhoer/flyway -url=jdbc:mysql://mydb -schemas=myschema -user=root -password=P@ssw0rd migrate

PowerShell:

docker run --rm -v C:\FolderWhereYourScriptsReside:/flyway/sql dhoer/flyway -url=jdbc:mysql://mydb -schemas=myschema -user=root -password=P@ssw0rd migrate

Windows 7 (Docker Toolbox)

docker run --rm -v /c/Users/FolderWhereYourScriptsReside:/flyway/sql dhoer/flyway -url=jdbc:mysql://mydb -schemas=myschema -user=root -password=P@ssw0rd migrate

Example docker-compose.yml

A compose file that will setup a database container and a container to perform migrations.

version: '2'
services:
  schema:
    image: dhoer/flyway
    command: -url=jdbc:mysql://db -schemas=myschema -user=root -password=P@ssw0rd migrate
    volumes:
      - .:/flyway/sql
    depends_on:
      - db
  db:
    image: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=P@ssw0rd
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    ports:
      - 3306:3306

Run docker-compose up -d db, wait a minute for MySQL to be initialized (or tail logs with docker-compose logs -f) then run docker-compose up schema.

Docker Pull Command
Owner
dhoer
Source Repository

Comments (0)