Skip to content

MariaDB: doctrine_migration_versions already exists #550

@4d4ch4u32

Description

@4d4ch4u32

I am using the Doctrine migrations bundle in a Docker Compose setup with MariaDB 11.4.

When I run the docker setup, the PHP entry point creates the database if it does not exist after connecting to the database. At this point the migration bundle tries to recreate the doctrine_migration_versions table and I get the error SQLSTATE[42S01]: Base table or view already exists: 1050 table 'doctrine_migration_versions' already exists.

The entrypoint script:

if [ -f ".env.test" ]; then
  echo "Waiting for test database to be ready..."
  if grep -q DATABASE_URL= .env.test; then
    php bin/console doctrine:database:create --env=test --if-not-exists
    if ls -A migrations/*.php >/dev/null 2>&1; then
      php bin/console doctrine:migrations:migrate --no-interaction --env=test
    fi
  else
    echo "The test database is not configured"
    exit 1
  fi
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions