Error when trying to reorder pages/chapters of a book #5273

Closed
opened 2026-02-05 09:53:04 +03:00 by OVERLORD · 20 comments
Owner

Originally created by @lucasplcorrea on GitHub (Apr 30, 2025).

Describe the Bug

Ao clicar em ordenar, uma mensagem de erro é exibida

Image

Steps to Reproduce

  1. Go to a shelve
  2. Select a book
  3. Try to sort a page/chapter

Expected Behaviour

Reordering book pages

Screenshots or Additional Context

When analyzing the logs in /app/www/storage/logs, searching for "sort", I received the following record:

[2025-04-30 13:01:50] production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' (Connection: mysql, SQL: select sort_rules.*, (select count(*) from books where sort_rules.id = books.sort_rule_id and books.deleted_at is null) as books_count from sort_rules order by name asc) (View: /app/www/resources/views/books/sort.blade.php) {"userId":5,"exception":"[object] (Illuminate\\View\\ViewException(code: 0): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' (Connection: mysql, SQL: select sort_rules.*, (select count(*) from books where sort_rules.id = books.sort_rule_id and books.deleted_at is null) as books_count from sort_rules order by name asc) (View: /app/www/resources/views/books/sort.blade.php) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825)
[previous exception] [object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' (Connection: mysql, SQL: select sort_rules.*, (select count(*) from books where sort_rules.id = books.sort_rule_id and books.deleted_at is null) as books_count from sort_rules order by name asc) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825)
[previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:407)

My environment runs on docker, BookStack version: v25.02.1
DB: Maria DB 11.4.5

Browser Details

No response

Exact BookStack Version

v25.02.1

Originally created by @lucasplcorrea on GitHub (Apr 30, 2025). ### Describe the Bug Ao clicar em ordenar, uma mensagem de erro é exibida ![Image](https://github.com/user-attachments/assets/c3a75d32-022a-4fcc-87cb-3d81ba4ea0e3) ### Steps to Reproduce 1. Go to a shelve 2. Select a book 3. Try to sort a page/chapter ### Expected Behaviour Reordering book pages ### Screenshots or Additional Context When analyzing the logs in /app/www/storage/logs, searching for "sort", I received the following record: ``` [2025-04-30 13:01:50] production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' (Connection: mysql, SQL: select sort_rules.*, (select count(*) from books where sort_rules.id = books.sort_rule_id and books.deleted_at is null) as books_count from sort_rules order by name asc) (View: /app/www/resources/views/books/sort.blade.php) {"userId":5,"exception":"[object] (Illuminate\\View\\ViewException(code: 0): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' (Connection: mysql, SQL: select sort_rules.*, (select count(*) from books where sort_rules.id = books.sort_rule_id and books.deleted_at is null) as books_count from sort_rules order by name asc) (View: /app/www/resources/views/books/sort.blade.php) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825) [previous exception] [object] (Illuminate\\Database\\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' (Connection: mysql, SQL: select sort_rules.*, (select count(*) from books where sort_rules.id = books.sort_rule_id and books.deleted_at is null) as books_count from sort_rules order by name asc) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825) [previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'books.sort_rule_id' in 'WHERE' at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:407) ``` My environment runs on docker, BookStack version: v25.02.1 DB: Maria DB 11.4.5 ### Browser Details _No response_ ### Exact BookStack Version v25.02.1
OVERLORD added the 🐕 Support label 2026-02-05 09:53:05 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Apr 30, 2025):

Hi @lucasplcorrea,
This error indicates that the database migrations were not run, or failed during run, when perform the upgrade to BookStack v25.02. Is this the default/standard (without modification) linuxserver docker image? If so, restart the bookstack container and it should show the migration status via the container logs during startup. Check those logs, and feel free to share them back here for further assistance if needed.

@ssddanbrown commented on GitHub (Apr 30, 2025): Hi @lucasplcorrea, This error indicates that the database migrations were not run, or failed during run, when perform the upgrade to BookStack v25.02. Is this the default/standard (without modification) linuxserver docker image? If so, restart the bookstack container and it should show the migration status via the container logs during startup. Check those logs, and feel free to share them back here for further assistance if needed.
Author
Owner

@lucasplcorrea commented on GitHub (Apr 30, 2025):

Yes, is a default linuxserver image, the startup log:

Illuminate\Database\QueryException 

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'sort_rules' already exists (Connection: mysql, SQL: create table `sort_rules` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `sequence` text not 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:825
    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    822▕                 );
    823▕             }
    824▕ 
  ➜ 825▕             throw new QueryException(
    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    827▕             );
    828▕         }
    829▕     }

      +9 vendor frames 

  10  /app/www/database/migrations/2025_01_29_180933_create_sort_rules_table.php:14
      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:    1000
User GID:    1000
───────────────────────────────────────
Linuxserver.io version: v25.02.1-ls198
Build-date: 2025-03-17T18:31:08+00:00
───────────────────────────────────────
    
using keys found in /config/keys
**** The following active confs have different version dates than the samples that are shipped. ****
**** This may be due to user customization or an update to the samples. ****
**** You should compare the following files to the samples in the same folder and update them. ****
**** Use the link at the top of the file to view the changelog. ****
┌────────────┬────────────┬────────────────────────────────────────────────────────────────────────┐
│  old date  │  new date  │ path                                                                   │
├────────────┼────────────┼────────────────────────────────────────────────────────────────────────┤
│ 2024-05-27 │ 2024-12-17 │ /config/nginx/nginx.conf                                               │
│ 2023-08-13 │ 2024-12-06 │ /config/nginx/ssl.conf                                                 │
└────────────┴────────────┴────────────────────────────────────────────────────────────────────────┘
Waiting for DB to be available

   INFO  Running migrations.  

  2025_01_29_180933_create_sort_rules_table ..................... 18.27ms FAIL

   Illuminate\Database\QueryException 

  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'sort_rules' already exists (Connection: mysql, SQL: create table `sort_rules` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `sequence` text not 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:825
    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    822▕                 );
    823▕             }
    824▕ 
  ➜ 825▕             throw new QueryException(
    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    827▕             );
    828▕         }
    829▕     }

      +9 vendor frames 

  10  /app/www/database/migrations/2025_01_29_180933_create_sort_rules_table.php:14
      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.

@lucasplcorrea commented on GitHub (Apr 30, 2025): Yes, is a default linuxserver image, the startup log: ``` Illuminate\Database\QueryException SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'sort_rules' already exists (Connection: mysql, SQL: create table `sort_rules` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `sequence` text not 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:825 821▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 822▕ ); 823▕ } 824▕ ➜ 825▕ throw new QueryException( 826▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 827▕ ); 828▕ } 829▕ } +9 vendor frames 10 /app/www/database/migrations/2025_01_29_180933_create_sort_rules_table.php:14 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: 1000 User GID: 1000 ─────────────────────────────────────── Linuxserver.io version: v25.02.1-ls198 Build-date: 2025-03-17T18:31:08+00:00 ─────────────────────────────────────── using keys found in /config/keys **** The following active confs have different version dates than the samples that are shipped. **** **** This may be due to user customization or an update to the samples. **** **** You should compare the following files to the samples in the same folder and update them. **** **** Use the link at the top of the file to view the changelog. **** ┌────────────┬────────────┬────────────────────────────────────────────────────────────────────────┐ │ old date │ new date │ path │ ├────────────┼────────────┼────────────────────────────────────────────────────────────────────────┤ │ 2024-05-27 │ 2024-12-17 │ /config/nginx/nginx.conf │ │ 2023-08-13 │ 2024-12-06 │ /config/nginx/ssl.conf │ └────────────┴────────────┴────────────────────────────────────────────────────────────────────────┘ Waiting for DB to be available INFO Running migrations. 2025_01_29_180933_create_sort_rules_table ..................... 18.27ms FAIL Illuminate\Database\QueryException SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'sort_rules' already exists (Connection: mysql, SQL: create table `sort_rules` (`id` int unsigned not null auto_increment primary key, `name` varchar(191) not null, `sequence` text not 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:825 821▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 822▕ ); 823▕ } 824▕ ➜ 825▕ throw new QueryException( 826▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 827▕ ); 828▕ } 829▕ } +9 vendor frames 10 /app/www/database/migrations/2025_01_29_180933_create_sort_rules_table.php:14 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. ```
Author
Owner

@ssddanbrown commented on GitHub (Apr 30, 2025):

Okay, so there's a clear issue.

  • Did you perform a database migration/import at any point recently?
  • Have you created/used any "Sort Rules" (Settings > Sort Rules) in the system yet?
@ssddanbrown commented on GitHub (Apr 30, 2025): Okay, so there's a clear issue. - Did you perform a database migration/import at any point recently? - Have you created/used any "Sort Rules" (Settings > Sort Rules) in the system yet?
Author
Owner

@lucasplcorrea commented on GitHub (Apr 30, 2025):

I haven't done any migration recently, but some time ago, I moved the system behind a domain, changing the URL; it was local and I published it on the internet.

That was the last major change I made to the system. On the other hand, I don't remember having reordered any pages since then.

In the system logs, I see records of book_sort already done after this migration, so I don't believe that's specifically the problem.

In addition, when I try to access the path you suggested: "Sort Rules" (Settings > Sort Rules), the same error occurs.

I searched the system logs for sort_rule_create/update/dele, but I didn't find any records of rules in that sense (I imagined that another user could have created something, but I didn't find anything).

Image
Image

@lucasplcorrea commented on GitHub (Apr 30, 2025): I haven't done any migration recently, but some time ago, I moved the system behind a domain, changing the URL; it was local and I published it on the internet. That was the last major change I made to the system. On the other hand, I don't remember having reordered any pages since then. In the system logs, I see records of book_sort already done after this migration, so I don't believe that's specifically the problem. In addition, when I try to access the path you suggested: "Sort Rules" (Settings > Sort Rules), the same error occurs. I searched the system logs for sort_rule_create/update/dele, but I didn't find any records of rules in that sense (I imagined that another user could have created something, but I didn't find anything). ![Image](https://github.com/user-attachments/assets/bfcef6a0-c938-46aa-bba9-f6653afd9dc9) ![Image](https://github.com/user-attachments/assets/78d9bc94-5d29-4d85-97c5-617264e89ebd)
Author
Owner

@ssddanbrown commented on GitHub (Apr 30, 2025):

Okay, thanks for the extra info.
Not sure what's occurred here. Either way, we'll need to align the database state so the database migrations can continue.

  • Are you using something to automatically update the container images used?
  • Are you familiar with managing/accessing a database like mysql?
  • Are you familiar with running commands inside a docker image?
@ssddanbrown commented on GitHub (Apr 30, 2025): Okay, thanks for the extra info. Not sure what's occurred here. Either way, we'll need to align the database state so the database migrations can continue. - Are you using something to automatically update the container images used? - Are you familiar with managing/accessing a database like mysql? - Are you familiar with running commands inside a docker image?
Author
Owner

@lucasplcorrea commented on GitHub (Apr 30, 2025):

1 - Yes, I use Watchtower, which automatically updates my containers
2 - Yes, I am. I use Dbeaver to connect to Bookstack's MariaDB when I need to. I've even done backup and restore tests directly from the Bookstack database a few times
3 - Yes, I am. They're the same ones used in Linux. To make things easier, I use 1Panel, which allows me to run commands inside the container.

@lucasplcorrea commented on GitHub (Apr 30, 2025): 1 - Yes, I use Watchtower, which automatically updates my containers 2 - Yes, I am. I use Dbeaver to connect to Bookstack's MariaDB when I need to. I've even done backup and restore tests directly from the Bookstack database a few times 3 - Yes, I am. They're the same ones used in Linux. To make things easier, I use 1Panel, which allows me to run commands inside the container.
Author
Owner

@ssddanbrown commented on GitHub (May 1, 2025):

Alrighty, thanks for the answers.

In regards to watchtower, I often hear of these kinds of errors occur in watch-tower based environments. Based on a quick previous look, i assume some kind of timeout can occur during the upgrade leaving things in a bad state.
I'd advise using it for notification of updates only (if possible), and make the updates manually.

Before anything else, backup your data. Especially the database.

Now, can you enter the database and drop the sort_rules table?
Once done, restart the BookStack container, watching the first start-up logs for any errors or, hopefully if things work, non-error migration notices. Report back any errors, otherwise you should see the sort_rules table get re-created, and you should no longer have errors.

@ssddanbrown commented on GitHub (May 1, 2025): Alrighty, thanks for the answers. In regards to watchtower, I often hear of these kinds of errors occur in watch-tower based environments. Based on a quick previous look, i assume some kind of timeout can occur during the upgrade leaving things in a bad state. I'd advise using it for notification of updates only (if possible), and make the updates manually. **_Before anything else, backup your data. Especially the database._** Now, can you enter the database and drop the `sort_rules` table? Once done, restart the BookStack container, watching the **first start-up** logs for any errors or, hopefully if things work, non-error migration notices. Report back any errors, otherwise you should see the `sort_rules` table get re-created, and you should no longer have errors.
Author
Owner

@lucasplcorrea commented on GitHub (May 2, 2025):

I apologize for the delay in responding, yesterday was a holiday in my city and I couldn't work on it.

I did what you asked, dropped the table, restarted the container, and adjusted the watchtower only for notifications. During the restart, I even saw that it executes the table creation migrations in question, but in Dbeaver they are not displayed, and the error persists when accessing the page reordering section.

I will send you some prints and logs for analysis.

[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:    1000
User GID:    1000
───────────────────────────────────────
Linuxserver.io version: v25.02.1-ls198
Build-date: 2025-03-17T18:31:08+00:00
───────────────────────────────────────
    
using keys found in /config/keys
**** The following active confs have different version dates than the samples that are shipped. ****
**** This may be due to user customization or an update to the samples. ****
**** You should compare the following files to the samples in the same folder and update them. ****
**** Use the link at the top of the file to view the changelog. ****
┌───────���────┬──────────   INFO  Running migrations.  

  2025_01_29_180933_create_sort_rules_table ..................... 49.51ms DONE
  2025_02_05_150842_add_sort_rule_id_to_books ................... 89.20ms DONE

[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:    1000
User GID:    1000
───────────────────────────────────────
Linuxserver.io version: v25.02.1-ls198
Build-date: 2025-03-17T18:31:08+00:00
───────────────────────────────────────
    
using keys found in /config/keys
**** The following active confs have different version dates than the samples that are shipped. ****
**** This may be due to user customization or an update to the samples. ****
**** You should compare the following files to the samples in the same folder and update them. ****
**** Use the link at the top of the file to view the changelog. ****
┌────────────┬────────────┬────────────────────────────────────────────────────────────────────────┐
│  old date  │  new date  │ path                                                                   │
├────────────┼────────────┼────────────────────────────────────────────────────────────────────────┤
│ 2024-05-27 │ 2024-12-17 │ /config/nginx/nginx.conf                                               │
│ 2023-08-13 │ 2024-12-06 │ /config/nginx/ssl.conf                                                 │
└────────────┴────────────┴────────────────────────────────────────────────────────────────────────┘
Waiting for DB to be available

   INFO  Nothing to migrate.  

[custom-init] No custom files found, skipping...
[ls.io-init] done.

if there is any way to perform this migration manually, maybe I could try it

before performing the action, I made a backup as suggested.

Image

Image

@lucasplcorrea commented on GitHub (May 2, 2025): I apologize for the delay in responding, yesterday was a holiday in my city and I couldn't work on it. I did what you asked, dropped the table, restarted the container, and adjusted the watchtower only for notifications. During the restart, I even saw that it executes the table creation migrations in question, but in Dbeaver they are not displayed, and the error persists when accessing the page reordering section. I will send you some prints and logs for analysis. ``` [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: 1000 User GID: 1000 ─────────────────────────────────────── Linuxserver.io version: v25.02.1-ls198 Build-date: 2025-03-17T18:31:08+00:00 ─────────────────────────────────────── using keys found in /config/keys **** The following active confs have different version dates than the samples that are shipped. **** **** This may be due to user customization or an update to the samples. **** **** You should compare the following files to the samples in the same folder and update them. **** **** Use the link at the top of the file to view the changelog. **** ┌───────���────┬────────── INFO Running migrations. 2025_01_29_180933_create_sort_rules_table ..................... 49.51ms DONE 2025_02_05_150842_add_sort_rule_id_to_books ................... 89.20ms DONE [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: 1000 User GID: 1000 ─────────────────────────────────────── Linuxserver.io version: v25.02.1-ls198 Build-date: 2025-03-17T18:31:08+00:00 ─────────────────────────────────────── using keys found in /config/keys **** The following active confs have different version dates than the samples that are shipped. **** **** This may be due to user customization or an update to the samples. **** **** You should compare the following files to the samples in the same folder and update them. **** **** Use the link at the top of the file to view the changelog. **** ┌────────────┬────────────┬────────────────────────────────────────────────────────────────────────┐ │ old date │ new date │ path │ ├────────────┼────────────┼────────────────────────────────────────────────────────────────────────┤ │ 2024-05-27 │ 2024-12-17 │ /config/nginx/nginx.conf │ │ 2023-08-13 │ 2024-12-06 │ /config/nginx/ssl.conf │ └────────────┴────────────┴────────────────────────────────────────────────────────────────────────┘ Waiting for DB to be available INFO Nothing to migrate. [custom-init] No custom files found, skipping... [ls.io-init] done. ``` if there is any way to perform this migration manually, maybe I could try it before performing the action, I made a backup as suggested. ![Image](https://github.com/user-attachments/assets/39b0b6d0-cbde-41c8-a4f5-2b904e79186b) ![Image](https://github.com/user-attachments/assets/4cbe42d3-06fc-4e01-b5f7-b58dd7a338ae)
Author
Owner

@lucasplcorrea commented on GitHub (May 5, 2025):

Any news regarding this case?

@lucasplcorrea commented on GitHub (May 5, 2025): Any news regarding this case?
Author
Owner

@ssddanbrown commented on GitHub (May 8, 2025):

@lucasplcorrea no, not really.
It's odd that the migrations are running, but you are not seeing changes.
Do these migrations lines (which you highlighted with a red border in your screenshot) re-appear when restarting the container? Or does something else show?

and the error persists when accessing the page reordering section.

What exactly is this error? What are you seeing? What are the logged messages?
Just wondering if it's actually the same error or something else at play.

@ssddanbrown commented on GitHub (May 8, 2025): @lucasplcorrea no, not really. It's odd that the migrations are running, but you are not seeing changes. Do these migrations lines (which you highlighted with a red border in your screenshot) re-appear when restarting the container? Or does something else show? > and the error persists when accessing the page reordering section. What exactly is this error? What are you seeing? What are the logged messages? Just wondering if it's actually the same error or something else at play.
Author
Owner

@lucasplcorrea commented on GitHub (May 8, 2025):

No, it only appeared once!
A new version of bookstack was recently released, is it safe to update? If I update, will these migrations run again?

In the logs I find the following error filtering by | grep sort

[2025-05-02 13:53:25] production.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) {"userId":5,"exception":"[object] (Illuminate\\View\\ViewException(code: 0): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825)
[previous exception] [object] (Illuminate\\Database\\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825)
[previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:407)

[2025-05-07 14:17:56] production.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) {"userId":5,"exception":"[object] (Illuminate\\View\\ViewException(code: 0): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825)
[previous exception] [object] (Illuminate\\Database\\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825)
[previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:407)
@lucasplcorrea commented on GitHub (May 8, 2025): No, it only appeared once! A new version of bookstack was recently released, is it safe to update? If I update, will these migrations run again? In the logs I find the following error filtering by | grep sort ``` [2025-05-02 13:53:25] production.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) {"userId":5,"exception":"[object] (Illuminate\\View\\ViewException(code: 0): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825) [previous exception] [object] (Illuminate\\Database\\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825) [previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:407) [2025-05-07 14:17:56] production.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) {"userId":5,"exception":"[object] (Illuminate\\View\\ViewException(code: 0): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) (View: /app/www/resources/views/books/sort.blade.php) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825) [previous exception] [object] (Illuminate\\Database\\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist (Connection: mysql, SQL: select `sort_rules`.*, (select count(*) from `books` where `sort_rules`.`id` = `books`.`sort_rule_id` and `books`.`deleted_at` is null) as `books_count` from `sort_rules` order by `name` asc) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:825) [previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:407) ```
Author
Owner

@ssddanbrown commented on GitHub (May 9, 2025):

No, it only appeared once!

Okay, that's what I'd expect from a working setup. Means the database state is stable.

If I update, will these migrations run again?

They shouldn't do, since they've already ran (and there's no further migrations in the recent patch releases).

2025-05-07 14:17:56] production.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist

This is so strange. I can't see how the table does not exist, since you saw the migrations run in the log, which would have had to create this table.
The most likely thing to me would be that there's maybe multiple instances getting mixed up here? Unlikely but it's something I've seen before when supporting people.

Otherwise, you could access a shell in the active BookStack container, then enter the /app/www folder in the container, and run: php artisan migrate:status | tail -n 5, just to help confirm which migrations have been run.
It's important that this is ran in the running container to be sure it's the instance seen via the browser.
You can maybe test this by running php artisan down via the same way. Access via the browser should then show a maintenance message. You could restore the instance via php artisan up.

@ssddanbrown commented on GitHub (May 9, 2025): > No, it only appeared once! Okay, that's what I'd expect from a working setup. Means the database state is stable. > If I update, will these migrations run again? They shouldn't do, since they've already ran (and there's no further migrations in the recent patch releases). > `2025-05-07 14:17:56] production.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bookstack.sort_rules' doesn't exist` This is so strange. I can't see how the table does not exist, since you saw the migrations run in the log, which would have had to create this table. The most likely thing to me would be that there's maybe multiple instances getting mixed up here? Unlikely but it's something I've seen before when supporting people. Otherwise, you could access a shell in the active BookStack container, then enter the `/app/www` folder in the container, and run: `php artisan migrate:status | tail -n 5`, just to help confirm which migrations have been run. It's important that this is ran in the running container to be sure it's the instance seen via the browser. You can maybe test this by running `php artisan down` via the same way. Access via the browser should then show a maintenance message. You could restore the instance via `php artisan up`.
Author
Owner

@lucasplcorrea commented on GitHub (May 9, 2025):

When I hit php artisan migrate:status | tail -n 5

Image

When I hit php artisan down

Image

And up

Image

@lucasplcorrea commented on GitHub (May 9, 2025): When I hit `php artisan migrate:status | tail -n 5` ![Image](https://github.com/user-attachments/assets/c1d82880-0a87-4e40-b067-fde76f463411) When I hit `php artisan down` ![Image](https://github.com/user-attachments/assets/a377c3c5-4edf-4635-92d6-172d7a722d22) And up ![Image](https://github.com/user-attachments/assets/5f246602-7a4d-4d3c-afde-85f6329ba61e)
Author
Owner

@ssddanbrown commented on GitHub (May 9, 2025):

That all looks as expected.

What about this from the BookStack container (ran like before)?

php artisan tinker --execute='dd(array_filter(Schema::getTables(), fn($table) => str_contains($table["name"], "sort")));'

This should tell us if the table exists from the PHP code perspective.

@ssddanbrown commented on GitHub (May 9, 2025): That all looks as expected. What about this from the BookStack container (ran like before)? ```bash php artisan tinker --execute='dd(array_filter(Schema::getTables(), fn($table) => str_contains($table["name"], "sort")));' ``` This should tell us if the table exists from the PHP code perspective.
Author
Owner

@lucasplcorrea commented on GitHub (May 9, 2025):

root@0bf709c923f8:/app/www# php artisan tinker --execute='dd(array_filter(Schema::getTables(), fn($table) => str_contains($table["name"]
, "sort")));'
[] // vendor/psy/psysh/src/ExecutionClosure.php(40) : eval()'d code:1
root@0bf709c923f8:/app/www# 

Image

@lucasplcorrea commented on GitHub (May 9, 2025): ``` root@0bf709c923f8:/app/www# php artisan tinker --execute='dd(array_filter(Schema::getTables(), fn($table) => str_contains($table["name"] , "sort")));' [] // vendor/psy/psysh/src/ExecutionClosure.php(40) : eval()'d code:1 root@0bf709c923f8:/app/www# ``` ![Image](https://github.com/user-attachments/assets/88e45cf3-8340-4380-8e79-e41c0d07496b)
Author
Owner

@ssddanbrown commented on GitHub (May 10, 2025):

Okay, that's super odd.
Maybe we just have to accept the table wasn't created here and create it manually.

Before that though, can you check your books table in the database and confirm if there's a sort_rule_id column (might be at the very end of the column list). Need to know if that column creation has also gone wrong.

@ssddanbrown commented on GitHub (May 10, 2025): Okay, that's super odd. Maybe we just have to accept the table wasn't created here and create it manually. Before that though, can you check your `books` table in the database and confirm if there's a `sort_rule_id` column (might be at the very end of the column list). Need to know if that column creation has also gone wrong.
Author
Owner

@lucasplcorrea commented on GitHub (May 12, 2025):

Yes, it is a very strange thing to happen, especially since there are logs indicating that the migrations have been completed. If you can help me create it manually, I would be grateful.

there is also no sort_rule_id table that you mentioned.

Image

@lucasplcorrea commented on GitHub (May 12, 2025): Yes, it is a very strange thing to happen, especially since there are logs indicating that the migrations have been completed. If you can help me create it manually, I would be grateful. there is also no sort_rule_id table that you mentioned. ![Image](https://github.com/user-attachments/assets/0f0b25b7-c617-43f8-8652-4b77a5229b43)
Author
Owner

@ssddanbrown commented on GitHub (May 13, 2025):

@lucasplcorrea Okay, lets try allowing the migrations to re-run.

Before anything, I'd strongly advise a full backup of the instance data, especially the database data.

In the database, look at the migrations tables.
Delete the latest two rows (with the highest IDs). The batch column value for these should both be 4.
These should be the 2025_01_29_180933_create_sort_rules_table and 2025_02_05_150842_add_sort_rule_id_to_books named migrations.

With that done, restart the BookStack container, watching first start-up logs again.
You should see these migrations run again, and this time hopefully you'll see the relevant database changes, with the sort_rules table appearing.

@ssddanbrown commented on GitHub (May 13, 2025): @lucasplcorrea Okay, lets try allowing the migrations to re-run. **_Before anything, I'd strongly advise a full backup of the instance data, especially the database data._** In the database, look at the `migrations` tables. Delete the latest two rows (with the highest IDs). The `batch` column value for these should both be `4`. These should be the `2025_01_29_180933_create_sort_rules_table` and `2025_02_05_150842_add_sort_rule_id_to_books` named migrations. With that done, restart the BookStack container, watching first start-up logs again. You should see these migrations run again, and this time hopefully you'll see the relevant database changes, with the `sort_rules` table appearing.
Author
Owner

@lucasplcorrea commented on GitHub (May 16, 2025):

Works like a charm. I deleted the rows as suggested, and on reboot the tables were recreated, I can order the pages again.

Thanks for the support. Now I will run the container update.

@lucasplcorrea commented on GitHub (May 16, 2025): Works like a charm. I deleted the rows as suggested, and on reboot the tables were recreated, I can order the pages again. Thanks for the support. Now I will run the container update.
Author
Owner

@ssddanbrown commented on GitHub (May 17, 2025):

Great news, Good to hear that finally worked! Not sure why it didn't before, very strange!

@ssddanbrown commented on GitHub (May 17, 2025): Great news, Good to hear that finally worked! Not sure why it didn't before, very strange!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5273