koel/docker

Migrating database failed

M1scer opened this issue · 1 comments

M1scer commented

i have tried mySQL, PostgreSQL and now a im at mariaDB.

At php artisan koel:init --no-assets i get following error:

************************************
*     KOEL INSTALLATION WIZARD     *
************************************

As a reminder, you can always install/upgrade manually following the guide at https://docs.koel.dev

  Clearing caches ....................... 28ms DONE
   INFO  .env file exists -- skipping.

  Retrieving app key ....................... 0ms DONE

   INFO  Using app key: H..........................

  Migrating database ....................... 157ms FAIL
   ERROR  Oops! Koel installation or upgrade didn't finish successfully.

   ERROR  Please check the error log at storage/logs/laravel.log and try again.

   ERROR  You can also visit https://docs.koel.dev for other options.

   ERROR  😥 Sorry for this. You deserve better.

The "laravel.log" file gives me following error:

Next Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'koel/interactions_song_id_foreign' of table 'koel/interactions' (SQL: ALTER TABLE songs CHANGE id id VARCHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`) in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php(546): Illuminate\Database\Connection->run()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php(109): Illuminate\Database\Connection->statement()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(439): Illuminate\Database\Schema\Blueprint->build()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(269): Illuminate\Database\Schema\Builder->build()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(338): Illuminate\Database\Schema\Builder->table()
#6 /var/www/html/database/migrations/2022_08_01_093952_use_uuids_for_song_ids.php(16): Illuminate\Support\Facades\Facade::__callStatic()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(488): Illuminate\Database\Migrations\Migration@anonymous->up()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(406): Illuminate\Database\Migrations\Migrator->runMethod()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(415): Illuminate\Database\Migrations\Migrator->Illuminate\Database\Migrations\{closure}()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(216): Illuminate\Database\Migrations\Migrator->runMigration()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/View/Components/Task.php(36): Illuminate\Database\Migrations\Migrator->Illuminate\Database\Migrations\{closure}()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(749): Illuminate\Console\View\Components\Task->render()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(216): Illuminate\Database\Migrations\Migrator->write()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(181): Illuminate\Database\Migrations\Migrator->runUp()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(124): Illuminate\Database\Migrations\Migrator->runPending()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(90): Illuminate\Database\Migrations\Migrator->run()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(626): Illuminate\Database\Console\Migrations\MigrateCommand->Illuminate\Database\Console\Migrations\{closure}()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(102): Illuminate\Database\Migrations\Migrator->usingConnection()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Database\Console\Migrations\MigrateCommand->handle()
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(661): Illuminate\Container\BoundMethod::call()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call()
#25 /var/www/html/vendor/symfony/console/Command/Command.php(291): Illuminate\Console\Command->execute()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(153): Symfony\Component\Console\Command\Command->run()

On Stackoverflow i found following answer but i still was not able to connect.

Unfortunately, my skills are also limited, which is why I did not get further.

My docker-compose.yml looks like:

    koelApp:
        container_name: koelApp
        hostname: koelApp
        image: phanan/koel
        depends_on:
          - koelDb
        # environment: (.env file is used with following settings):
          # - APP_KEY=Hxxxxxxxxxxxxxxxx
          # - DB_CONNECTION=mysql
          # - DB_HOST=koelDb
          # - DB_PORT=3306
          # - DB_USERNAME=koel
          # - DB_PASSWORD=xxxxxxxx
          # - DB_DATABASE=koel
        volumes:
          - ./koel/music:/music
          - ./koel/covers:/var/www/html/public/img/covers
          - ./koel/search_index:/var/www/html/storage/search-indexes
          
          # Set Timezone
          - /etc/timezone:/etc/timezone:ro
          - /etc/localtime:/etc/localtime:ro
        env_file:
          - ./koel/app/.env
        labels:
          - "traefik.http.routers.koel.entrypoints=websecure"
          - "traefik.http.routers.koel.rule=Host(`koel.domain.de`)"
          - "traefik.http.services.koel.loadbalancer.server.port=80"
          - "traefik.http.routers.koel.tls=true"
          - "traefik.http.routers.koel.tls.certresolver=myresolver"
        networks:
          - traefik
        logging:
          driver: "json-file"
          options:
            max-size: "200k"
            max-file: "5"

# Koel Db
    koelDb:
        container_name: koelDb
        hostname: koelDb
        image: mariadb:latest
        restart: unless-stopped
        volumes:
          - ./koel/db:/var/lib/mysql
          
          # Set Timezone
          - /etc/timezone:/etc/timezone:ro
          - /etc/localtime:/etc/localtime:ro
        environment:
          - MARIADB_ROOT_PASSWORD=xxxxxxxx
          - MARIADB_DATABASE=koel
          - MARIADB_USER=koel
          - MARIADB_PASSWORD=xxxxxxxx
        labels:
          - "traefik.http.services.koelDb.loadbalancer.server.port=80" # Dummy Port
        networks:
          - traefik
        logging:
          driver: "json-file"
          options:
            max-size: "200k"
            max-file: "5"

My server is a Raspberry pi 4 (8gb)

The only (main) difference between the provided compose file an the file i am using is, that i am using bind mounts instead of volumes. But while using volumes i run into the exact same issue.

M1scer commented

i managed to establish a connection using mySQL and a shorter DB Password.