Skip to content

Error on initial Bookstack App Setup using Docker Image on Azure (Multiple primary key defined (SQL: alter table role_user add primary key (user_id, role_id))) #4666

@Cobajar

Description

@Cobajar

Describe the Bug

I deployed bookstack as an Azure Web App, the image is pulled from Docker Hub (
linuxserver/bookstack:version-v23.10).

Azure MySql Flexible Server is used as the database, the Bookstack data is stored in a storage account and integrated as volume mapping.

So far so good, I designed this to work wonderfully for a PoC about half a year / year ago, but I now get the following error during the initial deployment:

Waiting for DB to be available

   INFO  Preparing database.  

  Creating migration table ......................................... 89ms DONE

   INFO  Running migrations.  

  2014_10_12_000000_create_users_table ............................ 320ms DONE
  2014_10_12_100000_create_password_resets_table .................. 157ms DONE
  2015_07_12_114933_create_books_table ............................. 63ms DONE
  2015_07_12_190027_create_pages_table ............................. 64ms DONE
  2015_07_13_172121_create_images_table ............................ 63ms DONE
  2015_07_27_172342_create_chapters_table .......................... 70ms DONE
  2015_08_08_200447_add_users_to_entities ......................... 134ms DONE
  2015_08_09_093534_create_page_revisions_table .................... 83ms DONE
  2015_08_16_142133_create_activities_table ........................ 67ms DONE
  2015_08_29_105422_add_roles_and_permissions ..................... 549ms 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â–•     }

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

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

I have also tested an older version (linuxserver/bookstack:version-v23.08.1), same issue.

Steps to Reproduce

This is a proof of concept, so we dont use private endpoints etc.

Create Azure Resources

  1. Create a Flexible Azure Database for MySQL (B1ms, MySQLVersion: 8.0, MySQL-Authentication)
  2. Create a Storage Account and Fileshare named "config"
  3. Create a Azure Web App (B1 Plan)

The following Configuration Parameters are used:

PUID=1000
PGID=1000
APP_URL=https://<nameofmybookstackapp>.azurewebsites.net
DB_HOST=<nameofmysql>.mysql.database.azure.com
DB_PORT=3306
DB_USER=<mysqladmin>
DB_PASS=<mysqlpasswd>
DB_DATABASE=bookstack
WEBSITES_CONTAINER_START_TIME_LIMIT=300
MYSQL_ATTR_SSL_CA=/config/DigiCertGlobalRootCA.crt.pem

The following path mappings are used:
/config is mapped to the fileshare "config" on the storage account

Dont forget to upload the CA-certificate from Azure Database (Flexible Server). Alternatively "require-secure-transport" can be disabled on the mysql server side.

We often provide various apps as an app service, we know that this can sometimes be a bit tricky. In this case I would need support for Bookstack.

Let me know, if there is any assistance needed in reproducing the issue.

Expected Behaviour

Database migration runs without any problems

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

linuxserver/bookstack:version-v23.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions