Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLSTATE Error during migration #203

Closed
1 task done
olorunfemidavis opened this issue Jan 12, 2024 · 4 comments
Closed
1 task done

SQLSTATE Error during migration #203

olorunfemidavis opened this issue Jan 12, 2024 · 4 comments

Comments

@olorunfemidavis
Copy link

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>
Copy link

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

@thespad
Copy link
Member

thespad commented Jan 12, 2024

  • OS:Docker Linux

PS C:\Users\Olorunfemi>

I believe this is a WSL issue as described here: #125

@LinuxServer-CI
Copy link
Collaborator

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

Copy link

This issue is locked due to inactivity

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

4 participants