Database deleted each time mysql container restarted

I try to deploy my app to Digitalocean droplet server running docker container on it. Yet whenever the mysql db container restated i find the database deleted when i access phpmyadmin dashboard hosted on the server.
I make sure the volumes are persistent but the db keeps deleting every time the mysql container restarts. Is this issue related to volumes? Here’s my docker-compose file:

version: "3.9"
services:
  backend:
    image: my/image_example:latest
    container_name: my-app
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: mysql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
    volumes:
      - ./documents:/app/documents
    depends_on:
      - db
    restart: unless-stopped
    networks:
      - my-network

  db:
    image: mysql:8.0
    container_name: my-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    ports:
      - "${DB_PORT}:3306"
    volumes:
      - ./prod-db.sql:/docker-entrypoint-initdb.d/schema.sql:ro
      - db_data:/var/lib/mysql
    networks:
      - my-network
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: always
    environment:
      PMA_HOST: ${PMA_HOST}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    ports:
      - "8080:80"
    depends_on:
      - db
    networks:
      - my-network

networks:
  my-network:
    driver: bridge
    name: my-network

volumes:
  db_data:

We don’t know what’s in that file, maybe dropping and creating tables?

The sql schema to initiate my database.

And what is in the mysql container logs? When it starts, I think it should show if it initialized something or did anything else relevanrt.

According to the image description, the init files are applied when the container starts the first time, so ti should not delete anything normally even if there is a drop in the sql file.

Since volumes are not deleted when you restart a container, if it is really a restart and not a docker compose down with “-v”, data could be deleted only if something in the container deletes it or something outside the container deletes unused volumes and the container is not just restarted but recreated.

I would also try pull the MySQL image again just in case there was a bug in an earlier version and you still had an old 8.0.x. Or you can just set the image tag to a more specific version like 8.0.43