I want to run command conditionally in docker-compose

because when someone run this application at first time,

They would have to run `migrate` command so that they can run `django` application properly

But If their docker have run `migrate`, there is no need to run `migrate` again

So this is the command to check that their docker have run `migrate`.

```
    if [[ -z $(python3 zeus/manage.py showmigrations | grep '\[ \]')]]; then
        echo 'no need to migrate'
    else
        echo 'need to migate'
    fi

```

This is my docker-compose.

```
version: '3'

services:
  db:
    image: postgres
  web:
    command: >
         bash -c "if [[ -z $(python3 zeus/manage.py showmigrations | grep '\[ \]')]]; then
               echo 'no need to migrate'
            else
               echo 'need to migate'
            fi && python3 zeus/manage.py runserver 0.0.0.0:8000
         "

```

But Error occurs like this

```
ERROR: Invalid interpolation format for "build" option in service 
"web": "bash -c "if [[ -z $(python3 zeus/manage.py showmigrations | grep '\[ \]')]]; then 
echo 'no need to migrate' else echo 'need to migate' fi 
&& python3 zeus/manage.py runserver 0.0.0.0:8000""

```

Any idea?

Edit
----

This is fine when I run the script of checking migration in normal bash

I think docker-compose can't parse `$(python3 manage.py .....)` part.