<h1>The problem</h1>
<p>I have a flyway job that is meant to be performing migrations on a postgres database.
The job doesn't seem to be running the command and inspection of the jobs logs only output flyway documentation.</p>
<h2>Expectations</h2>
<p>I expect the log inspection to be a synopsis of the migrations occurred.
I also have installed pgweb to allow for observability and after connecting to my postgres pod, it is clear no tables have been created at all.</p>
<p>Here is a photo of the expected output from kubectl logs flyway-pod
<a href="https://i.stack.imgur.com/Xj0ku.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xj0ku.png" alt="Migrations expected output" /></a></p>
<h2>What I get</h2>
<p>This is the output of kubectl logs flyway-pod
<a href="https://i.stack.imgur.com/bZ61C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bZ61C.png" alt="Flyway Logs output" /></a>
As you can see it prints the usage guide rather than a sign that the migration occurred.</p>
<h2>What I have tried -explanation</h2>
<p>I have so far been moving the connection command around.</p>
<p>I have commented out the locations where I have tried placing the command.
I have tried it in 3 locations.</p>
<ol>
<li>Inside the original Flyway Dockerfile and nowhere else.</li>
<li>Inside the docker compose file near the flyway service and nowhere else.</li>
<li>Inside the Kubernetes Flyway job and nowhere else.</li>
</ol>
<h1>Code</h1>
<p>Here are my files and setup.</p>
<h2>Kubernetes files</h2>
<p>What follows are the relevant Kubernetes files used to setup my cluster.</p>
<h3>Flyway Job:</h3>
<p>Here is the Flyway job:</p>
<pre><code>kind: Job
metadata:
  name: flyway-migration-job
spec:
  template:
    spec:
      containers:
      - name: flyway
        image: flyway/flyway:6.3.1
        command: [&quot;flyway&quot;, &quot;-url=jdbc:postgresql://postgres-master:5432/wallet&quot;, &quot;-user=test_user&quot;, &quot;-password=testuser1234&quot;, &quot;-schemas=wallet&quot;, &quot;-connectRetries=60 migrate&quot;]
      restartPolicy: OnFailure
</code></pre>
<h3>Postgres Deployment and Service</h3>
<h4>Postgres Deployment file</h4>
<pre><code>kind: Deployment
metadata:
  name: postgres-master
  labels:
    app: postgres-master
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres-master
  template:
    metadata:
      labels:
        app: postgres-master
    spec:
      containers:
        - name: postgres-master
          image: postgres:13
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 5432
          env:
            - name: POSTGRES_DB
              value: wallet
            - name: POSTGRES_USER
              value: test_user
            - name: POSTGRES_PASSWORD
              value: testuser1234
      
</code></pre>
<h4>Postgres service</h4>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: postgres-master
  labels: 
    app: postgres-master
spec: 
  type: NodePort
  ports:
    - protocol: TCP
      port: 5432
      targetPort: 5432
  selector: 
    app: postgres-master
</code></pre>
<h2>Docker files</h2>
<p>As I am building my images locally and pulling them into my cluster using kind, I will attach my relevant Dockerfiles.</p>
<h3>Flyway Dockerfile</h3>
<pre><code>FROM flyway/flyway:7.7.3-alpine

COPY ./migrations/sql /flyway/sql/

#CMD [&quot;flyway -url=jdbc:postgresql://postgres-master:5432/wallet -user=test_user -password=testuser1234  -connectRetries=60 -schemas=wallet migrate&quot;]
</code></pre>
<h3>Flyway SQL script</h3>
<p>This script is stored inside migrations/sql</p>
<pre><code>CREATE TABLE wallet.transaction_events (
    transaction_version int,
    transaction_type VARCHAR(200),
    coins int,
    transaction_id VARCHAR(500),
    wallet_id VARCHAR(500)
)
</code></pre>
<h3>Docker compose</h3>
<p>Here is the docker compose file that I use to build my images before pulling into kind/my cluster.</p>
<pre><code>version: '3.5'
services:
  web:
    build:
      dockerfile: ./Dockerfile
    container_name: wallet-api-web
    depends_on: 
      - flyway
    ports: 
      - &quot;8080:8080&quot;
  postgres-db:
    build:
      dockerfile: ./utils/db.Dockerfile
    container_name: postgres-db
    environment:
      POSTGRES_PASSWORD: testuser1234
      POSTGRES_USER: test_user
      POSTGRES_DB: wallet
    image: postgres:13
    ports:
      - &quot;5432:5432&quot;
    restart: always

  flyway:
    build:
      dockerfile: ./migrations/Dockerfile
    #command: -url=jdbc:postgresql://postgres-master:5432/wallet -user=test_user -password=testuser1234 -schemas=wallet -connectRetries=60 migrate 
    container_name: flyway-migrations
    depends_on:
      - db
    image: flyway/flyway:6.3.1
    volumes:
      - ${PWD}/migrations/sql:/flyway/sql

</code></pre>
<p>I think I have covered everything required to provide context to my problem but if any clarifications are required feel free to ask.</p>
<p>I really appreciate any help with getting these migrations working.
Thank you</p>

befoca1956
<p>You command is in array syntax, that means that each parameter must be a separate element.
You have two parameters in the last element, which flyway does not understand.</p>
<p>To fix:</p>
<pre><code>&quot;-connectRetries=60 migrate&quot;]
</code></pre>
<p>change to</p>
<pre><code>&quot;-connectRetries=60&quot;, &quot;migrate&quot;]
</code></pre>
