Skip to content

SQLSTATE Error during migration #203

@olorunfemidavis

Description

@olorunfemidavis

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Starting the container fails at Migration during roles.

2015_08_29_105422_add_roles_and_permissions ................... 1,943ms FAIL
2024-01-12 16:35:27 SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined (SQL: alter table role_user add primary key (user_id, role_id))
2024-01-12 16:35:27
2024-01-12 16:35:27 at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
2024-01-12 16:35:27 756▕ // If an exception occurs when attempting to run a query, we'll format the error
2024-01-12 16:35:27 757▕ // message to include the bindings with SQL, which will make this exception a
2024-01-12 16:35:27 758▕ // lot more helpful to the developer instead of just the database's errors.
2024-01-12 16:35:27 759▕ catch (Exception $e) {
2024-01-12 16:35:27 ➜ 760▕ throw new QueryException(
2024-01-12 16:35:27 761▕ $query, $this->prepareBindings($bindings), $e
2024-01-12 16:35:27 762▕ );
2024-01-12 16:35:27 763▕ }
2024-01-12 16:35:27 764▕ }
2024-01-12 16:35:27
2024-01-12 16:35:27 +9 vendor frames
2024-01-12 16:35:27 10 /app/www/database/migrations/2015_08_29_105422_add_roles_and_permissions.php:35
2024-01-12 16:35:27 Illuminate\Support\Facades\Facade::__callStatic()

Expected Behavior

Successful Migration and application startup.

Steps To Reproduce

Create a docker.compose.yml file

Run this command in the root of the file:
docker-compose up -d

Open docker to see the result.

Environment

- OS:Docker Linux
- How docker service was installed: lscr.io/linuxserver/bookstack:latest

CPU architecture

x86-64

Docker creation

version: '2'

services:
   bookstack:
     image: lscr.io/linuxserver/bookstack:latest
     container_name: bookstack
     ports:
       - "6875:80"
     restart: always
     environment:
       APP_URL: http://localhost:6875
       DB_USER: bookstackuser
       DB_HOST: db-dev.mysql.database.azure.com:3306
       DB_PASS: "F90v"
       DB_DATABASE: bookstackapp
       DB_CONNECTION: mysql
     volumes:
        - bookstackdata:/config
volumes:
  bookstackdata:


### Container logs

```bash
PS C:\Users\Olorunfemi> docker logs bookstack
[migrations] started
[migrations] 01-nginx-site-confs-default: skipped
[migrations] 02-default-location: skipped
[migrations] done
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    911
User GID:    911
───────────────────────────────────────

using keys found in /config/keys
App Key found - setting variable for seds
Running config - DB_HOST set
Waiting for DB to be available

   INFO  Running migrations.

  2015_08_29_105422_add_roles_and_permissions ..................... 225ms FAIL

   Illuminate\Database\QueryException

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'roles' already exists (SQL: create table `roles` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `display_name` varchar(191) null, `description` varchar(191) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +9 vendor frames
  10  /app/www/database/migrations/2015_08_29_105422_add_roles_and_permissions.php:26
      Illuminate\Support\Facades\Facade::__callStatic()

      +25 vendor frames
  36  /app/www/artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
[custom-init] No custom files found, skipping...
[ls.io-init] done.
[migrations] started
[migrations] 01-nginx-site-confs-default: skipped
[migrations] 02-default-location: skipped
[migrations] done
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    911
User GID:    911
───────────────────────────────────────

using keys found in /config/keys
App Key found - setting variable for seds
Running config - DB_HOST set
Waiting for DB to be available

   INFO  Preparing database.

  Creating migration table ........................................ 319ms DONE

   INFO  Running migrations.

  2014_10_12_000000_create_users_table ............................ 835ms DONE
  2014_10_12_100000_create_password_resets_table .................. 835ms DONE
  2015_07_12_114933_create_books_table ............................ 324ms DONE
  2015_07_12_190027_create_pages_table ............................ 291ms DONE
  2015_07_13_172121_create_images_table ........................... 297ms DONE
  2015_07_27_172342_create_chapters_table ......................... 286ms DONE
  2015_08_08_200447_add_users_to_entities ....................... 1,049ms DONE
  2015_08_09_093534_create_page_revisions_table ................... 300ms DONE
  2015_08_16_142133_create_activities_table ....................... 287ms DONE
  2015_08_29_105422_add_roles_and_permissions ................... 1,943ms FAIL

   Illuminate\Database\QueryException

  SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined (SQL: alter table `role_user` add primary key (`user_id`, `role_id`))

  at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +9 vendor frames
  10  /app/www/database/migrations/2015_08_29_105422_add_roles_and_permissions.php:35
      Illuminate\Support\Facades\Facade::__callStatic()

      +25 vendor frames
  36  /app/www/artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
[custom-init] No custom files found, skipping...
[ls.io-init] done.
PS C:\Users\Olorunfemi>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions