Bookstack give "Unable to create or change a table without a primary key" error #2141

Closed
opened 2026-02-05 03:05:34 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @dharmendrakariya on GitHub (Mar 5, 2021).

Describe the bug
When we used Digital Ocean managed mysql DB, Bookstack is throwing "Unable to create or change a table without a primary key" error because cache, password_resets, and sessions tables don't have primary key.

Steps To Reproduce
Steps to reproduce the behavior:

  1. I am using Helm Release, Apply the below helm release values
values:
    image:
      # repository: linuxserver/bookstack
      # tag: version-v0.31.1
      repository: solidnerd/bookstack
      tag: 0.29.3
    env: 
      APP_DEBUG: true
    externalDatabase:
      ## Database host
      host: private-mysql-1-do-user-**-0.b.db.ondigitalocean.com:25060   # DO
      # host: mysql:3306
      
      ## Database user
      user: bookstack   # DO
     
      ## Database password
      password: fo**c5***auqq  # DO
     
      ## Database name
      database: bookstack  # DO
     

    mariadb:
      ## Whether to deploy a mariadb server to satisfy the applications database requirements. To use an external database set this to false and configure the externalDatabase parameters
      enabled: false
    ingress:
      enabled: true
      # annotations: 
      #   kubernetes.io/ingress.class: nginx
      #   kubernetes.io/tls-acme: "true"
      path: /
      #backend:
        #serviceName: {{ $fullName }}
        #servicePort: 80
      hosts:
        - wiki.dnskladn

    resources: 
      # We usually recommend not to specify default resources and to leave this as a conscious
      # choice for the user. This also increases chances charts run on environments with little
      # resources, such as Minikube. If you do want to specify resources, uncomment the following
      # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
      limits:
       cpu: 200m
       memory: 256Mi
      requests:
       cpu: 150m
       memory: 128Mi

Expected behavior
Bookstack should be up and running.

Screenshots
bookstack-error

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): BookStack v0.29.3
  • Hosting Method (Nginx/Apache/Docker): Docker/Kubernetes

Additional context
Add any other context about the problem here.

Originally created by @dharmendrakariya on GitHub (Mar 5, 2021). **Describe the bug** When we used Digital Ocean managed mysql DB, Bookstack is throwing "Unable to create or change a table without a primary key" error because ```cache```, ```password_resets```, and ```sessions``` tables don't have primary key. **Steps To Reproduce** Steps to reproduce the behavior: 1. I am using Helm Release, Apply the below helm release values ``` values: image: # repository: linuxserver/bookstack # tag: version-v0.31.1 repository: solidnerd/bookstack tag: 0.29.3 env: APP_DEBUG: true externalDatabase: ## Database host host: private-mysql-1-do-user-**-0.b.db.ondigitalocean.com:25060 # DO # host: mysql:3306 ## Database user user: bookstack # DO ## Database password password: fo**c5***auqq # DO ## Database name database: bookstack # DO mariadb: ## Whether to deploy a mariadb server to satisfy the applications database requirements. To use an external database set this to false and configure the externalDatabase parameters enabled: false ingress: enabled: true # annotations: # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" path: / #backend: #serviceName: {{ $fullName }} #servicePort: 80 hosts: - wiki.dnskladn resources: # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little # resources, such as Minikube. If you do want to specify resources, uncomment the following # lines, adjust them as necessary, and remove the curly braces after 'resources:'. limits: cpu: 200m memory: 256Mi requests: cpu: 150m memory: 128Mi ``` **Expected behavior** Bookstack should be up and running. **Screenshots** ![bookstack-error](https://user-images.githubusercontent.com/22043860/110083312-8f7f4500-7db4-11eb-8452-f82424288c8d.png) **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): BookStack v0.29.3 - Hosting Method (Nginx/Apache/Docker): Docker/Kubernetes **Additional context** Add any other context about the problem here.
Author
Owner

@ssddanbrown commented on GitHub (Mar 6, 2021):

Thanks for providing the detail @dharmendrakariya.

A related issue for the framework we use can be seen here: https://github.com/laravel/framework/issues/33238

I'd be somewhat hesitant to change our database migration files or add workarounds within the core project just because of the enforced limitations from a single cloud provider. I don't mind adding primary keys to the relevant rows but we can't do that in a nice progressive manner since it would still create errors for you, we'd have to alter old migrations which has its own implications.

@ssddanbrown commented on GitHub (Mar 6, 2021): Thanks for providing the detail @dharmendrakariya. A related issue for the framework we use can be seen here: https://github.com/laravel/framework/issues/33238 I'd be somewhat hesitant to change our database migration files or add workarounds within the core project just because of the enforced limitations from a single cloud provider. I don't mind adding primary keys to the relevant rows but we can't do that in a nice progressive manner since it would still create errors for you, we'd have to alter old migrations which has its own implications.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2141