'Symfony5 workflow with githubaction issue on database and migrations

Currently, I'm trying to set up a workflow with GitHub action. I took example from https://github.com/shivammathur/setup-php/blob/master/examples/symfony-mysql.yml

My ci.yml is:

name: phpunit
on: [push]

jobs:

  tests :
    name: Running functional and unit test
    runs-on: ubuntu-20.04
    services:
      mysql:
        image: mysql:5.7
        env:
          MYSQL_ALLOW_EMPTY_PASSWORD: false
          MYSQL_ROOT_PASSWORD: symfony
          MYSQL_DATABASE: symfony
        ports:
          - 3306/tcp
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    strategy:
      fail-fast: true
      matrix:
        php-versions: ['7.4-apache']

    steps: 
      # —— Setup Github actions 🐙 —————————————————————————————————————————————
      # https://github.com/actions/checkout (official)
        - name: Checkout
          uses: actions/checkout@v2

      # https://github.com/shivammathur/setup-php (community)
        - name: Setup PHP, extensions and composer with shivammathur/setup-php
          uses: shivammathur/setup-php@v2
          with:
            php-version: ${{ matrix.php-versions }}
            extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, iconv, json, mbstring, mysqli
          env:
            update: true

        - name: Check PHP Version
          run: php -v

        
          # —— Composer 🧙‍️ —————————————————————————————————————————————————————————
        - name: Validate composer.json and composer.lock
          run: composer validate

        - name: Get composer cache directory
          id: composer-cache
          run: echo "::set-output name=dir::$(composer config cache-files-dir)"

        - name: Cache composer dependencies
          uses: actions/cache@v1
          with:
            path: ${{ steps.composer-cache.outputs.dir }}
            key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
            restore-keys: ${{ runner.os }}-composer-

        - name: Install Composer dependencies
          run: composer install --no-progress --prefer-dist --optimize-autoloader

        - run: composer require symfony/runtime 

        - name: Run Migration && Load Fixtures
          run: |
            composer require --dev symfony/orm-pack
            php bin/console doctrine:database:drop --if-exists --force --env=test
            php bin/console doctrine:database:create --if-not-exists --env=test
            php bin/console doctrine:schema:update --env=test --force || echo "No migrations found or schema update failed"
            php bin/console doctrine:migrations:migrate --env=test || echo "No migrations found or migration failed"
            php bin/console doctrine:fixtures:load --no-interaction
          env:
           DATABASE_URL: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/symfony
            
        

         ## —— NPM 🐱 ————————————————————————————————————————————————————————————
        - name: npm install
          uses: actions/setup-node@v2
          with:
            node-version: '14'
            #registry-url: npm.fontawesome.com
        - run: npm install
            #env:
          #NODE_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}

        - run: npm run build
        - run: php bin/phpunit

I'm getting issue in the step of Run migrations & load Fixtures': ci error:
ci error

Ci error:
ci error

Error:  Migration DoctrineMigrations\Version20220222101244 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user' already exists"

In ExceptionConverter.php line 47:
                                                                               
  An exception occurred while executing a query: SQLSTATE[42S01]: Base table   
  or view already exists: 1050 Table 'user' already exists  

I tried to remove schema update, this also lead into another error. I also removed dropping database, then another error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source