Could not update from 22.10.2 to 23.01: Unknown column 'pages.restricted' #3485

Closed
opened 2026-02-05 06:51:49 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @bendem on GitHub (Feb 1, 2023).

Describe the Bug

After starting v23.01, the interface is not accessible. The migrations failed with

Waiting for DB to be available
Migrating: 2022_10_08_104202_drop_entity_restricted_field

   Illuminate\Database\QueryException

  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pages.restricted' in 'on clause' (SQL: select `entity_permissions`.`id` as `id` from `entity_permissions` inner join `pages` on `pages`.`restricted` = 0 and `pages`.`id` = `entity_permissions`.`entity_id` where `entity_type` = page)

  at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

      +9 vendor frames
  10  /app/www/database/migrations/2022_10_08_104202_drop_entity_restricted_field.php:26
      Illuminate\Database\Query\Builder::pluck()

  11  /app/www/database/migrations/2022_10_08_104202_drop_entity_restricted_field.php:29
      DropEntityRestrictedField::{closure}()

Steps to Reproduce

Setup 22.10.2, start 23.01.

Expected Behaviour

No error

Screenshots or Additional Context

Migration table correctly show the previous migrations were applied:

select * from migrations;
+----+----------------------------------------------------------+-------+
| id | migration                                                | batch |
+----+----------------------------------------------------------+-------+
|  1 | 2014_10_12_000000_create_users_table                     |     1 |
|  2 | 2014_10_12_100000_create_password_resets_table           |     1 |
|  3 | 2015_07_12_114933_create_books_table                     |     1 |
|  4 | 2015_07_12_190027_create_pages_table                     |     1 |
|  5 | 2015_07_13_172121_create_images_table                    |     1 |
|  6 | 2015_07_27_172342_create_chapters_table                  |     1 |
|  7 | 2015_08_08_200447_add_users_to_entities                  |     1 |
|  8 | 2015_08_09_093534_create_page_revisions_table            |     1 |
|  9 | 2015_08_16_142133_create_activities_table                |     1 |
| 10 | 2015_08_29_105422_add_roles_and_permissions              |     1 |
| 11 | 2015_08_30_125859_create_settings_table                  |     1 |
| 12 | 2015_08_31_175240_add_search_indexes                     |     1 |
| 13 | 2015_09_04_165821_create_social_accounts_table           |     1 |
| 14 | 2015_09_05_164707_add_email_confirmation_table           |     1 |
| 15 | 2015_11_21_145609_create_views_table                     |     1 |
| 16 | 2015_11_26_221857_add_entity_indexes                     |     1 |
| 17 | 2015_12_05_145049_fulltext_weighting                     |     1 |
| 18 | 2015_12_07_195238_add_image_upload_types                 |     1 |
| 19 | 2015_12_09_195748_add_user_avatars                       |     1 |
| 20 | 2016_01_11_210908_add_external_auth_to_users             |     1 |
| 21 | 2016_02_25_184030_add_slug_to_revisions                  |     1 |
| 22 | 2016_02_27_120329_update_permissions_and_roles           |     1 |
| 23 | 2016_02_28_084200_add_entity_access_controls             |     1 |
| 24 | 2016_03_09_203143_add_page_revision_types                |     1 |
| 25 | 2016_03_13_082138_add_page_drafts                        |     1 |
| 26 | 2016_03_25_123157_add_markdown_support                   |     1 |
| 27 | 2016_04_09_100730_add_view_permissions_to_roles          |     1 |
| 28 | 2016_04_20_192649_create_joint_permissions_table         |     1 |
| 29 | 2016_05_06_185215_create_tags_table                      |     1 |
| 30 | 2016_07_07_181521_add_summary_to_page_revisions          |     1 |
| 31 | 2016_09_29_101449_remove_hidden_roles                    |     1 |
| 32 | 2016_10_09_142037_create_attachments_table               |     1 |
| 33 | 2017_01_21_163556_create_cache_table                     |     1 |
| 34 | 2017_01_21_163602_create_sessions_table                  |     1 |
| 35 | 2017_03_19_091553_create_search_index_table              |     1 |
| 36 | 2017_04_20_185112_add_revision_counts                    |     1 |
| 37 | 2017_07_02_152834_update_db_encoding_to_ut8mb4           |     1 |
| 38 | 2017_08_01_130541_create_comments_table                  |     1 |
| 39 | 2017_08_29_102650_add_cover_image_display                |     1 |
| 40 | 2018_07_15_173514_add_role_external_auth_id              |     1 |
| 41 | 2018_08_04_115700_create_bookshelves_table               |     1 |
| 42 | 2019_07_07_112515_add_template_support                   |     1 |
| 43 | 2019_08_17_140214_add_user_invites_table                 |     1 |
| 44 | 2019_12_29_120917_add_api_auth                           |     1 |
| 45 | 2020_08_04_111754_drop_joint_permissions_id              |     1 |
| 46 | 2020_08_04_131052_remove_role_name_field                 |     1 |
| 47 | 2020_09_19_094251_add_activity_indexes                   |     1 |
| 48 | 2020_09_27_210059_add_entity_soft_deletes                |     1 |
| 49 | 2020_09_27_210528_create_deletions_table                 |     1 |
| 50 | 2020_11_07_232321_simplify_activities_table              |     1 |
| 51 | 2020_12_30_173528_add_owned_by_field_to_entities         |     1 |
| 52 | 2021_01_30_225441_add_settings_type_column               |     2 |
| 53 | 2021_03_08_215138_add_user_slug                          |     2 |
| 54 | 2021_05_15_173110_create_favourites_table                |     3 |
| 55 | 2021_06_30_173111_create_mfa_values_table                |     4 |
| 56 | 2021_07_03_085038_add_mfa_enforced_to_roles_table        |     4 |
| 57 | 2021_08_28_161743_add_export_role_permission             |     4 |
| 58 | 2021_09_26_044614_add_activities_ip_column               |     5 |
| 59 | 2021_11_26_070438_add_index_for_user_ip                  |     6 |
| 60 | 2021_12_07_111343_create_webhooks_table                  |     7 |
| 61 | 2021_12_13_152024_create_jobs_table                      |     7 |
| 62 | 2021_12_13_152120_create_failed_jobs_table               |     7 |
| 63 | 2022_01_03_154041_add_webhooks_timeout_error_columns     |     7 |
| 64 | 2022_04_17_101741_add_editor_change_field_and_permission |     8 |
| 65 | 2022_04_25_140741_update_polymorphic_types               |     8 |
| 66 | 2022_07_16_170051_drop_joint_permission_type             |     9 |
| 67 | 2022_08_17_092941_create_references_table                |    10 |
| 68 | 2022_09_02_082910_fix_shelf_cover_image_types            |    10 |
| 69 | 2022_10_07_091406_flatten_entity_permissions_table       |    10 |
+----+----------------------------------------------------------+-------+
69 rows in set (0.00 sec)

This is probably related to #3714, but I'm not getting the same error and the other issue is closed.

Since all previous migrations were applied correctly, I'm opening a bug report.

Browser Details

N/A

Exact BookStack Version

23.01

PHP Version

8.1

Hosting Environment

Using docker.io/linuxserver/bookstack:version-v23.01

Originally created by @bendem on GitHub (Feb 1, 2023). ### Describe the Bug After starting v23.01, the interface is not accessible. The migrations failed with ``` Waiting for DB to be available Migrating: 2022_10_08_104202_drop_entity_restricted_field Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pages.restricted' in 'on clause' (SQL: select `entity_permissions`.`id` as `id` from `entity_permissions` inner join `pages` on `pages`.`restricted` = 0 and `pages`.`id` = `entity_permissions`.`entity_id` where `entity_type` = page) at /app/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:712 708▕ // If an exception occurs when attempting to run a query, we'll format the error 709▕ // message to include the bindings with SQL, which will make this exception a 710▕ // lot more helpful to the developer instead of just the database's errors. 711▕ catch (Exception $e) { ➜ 712▕ throw new QueryException( 713▕ $query, $this->prepareBindings($bindings), $e 714▕ ); 715▕ } 716▕ } +9 vendor frames 10 /app/www/database/migrations/2022_10_08_104202_drop_entity_restricted_field.php:26 Illuminate\Database\Query\Builder::pluck() 11 /app/www/database/migrations/2022_10_08_104202_drop_entity_restricted_field.php:29 DropEntityRestrictedField::{closure}() ``` ### Steps to Reproduce Setup 22.10.2, start 23.01. ### Expected Behaviour No error ### Screenshots or Additional Context Migration table correctly show the previous migrations were applied: <details> <summary><code>select * from migrations;</code></summary> ``` +----+----------------------------------------------------------+-------+ | id | migration | batch | +----+----------------------------------------------------------+-------+ | 1 | 2014_10_12_000000_create_users_table | 1 | | 2 | 2014_10_12_100000_create_password_resets_table | 1 | | 3 | 2015_07_12_114933_create_books_table | 1 | | 4 | 2015_07_12_190027_create_pages_table | 1 | | 5 | 2015_07_13_172121_create_images_table | 1 | | 6 | 2015_07_27_172342_create_chapters_table | 1 | | 7 | 2015_08_08_200447_add_users_to_entities | 1 | | 8 | 2015_08_09_093534_create_page_revisions_table | 1 | | 9 | 2015_08_16_142133_create_activities_table | 1 | | 10 | 2015_08_29_105422_add_roles_and_permissions | 1 | | 11 | 2015_08_30_125859_create_settings_table | 1 | | 12 | 2015_08_31_175240_add_search_indexes | 1 | | 13 | 2015_09_04_165821_create_social_accounts_table | 1 | | 14 | 2015_09_05_164707_add_email_confirmation_table | 1 | | 15 | 2015_11_21_145609_create_views_table | 1 | | 16 | 2015_11_26_221857_add_entity_indexes | 1 | | 17 | 2015_12_05_145049_fulltext_weighting | 1 | | 18 | 2015_12_07_195238_add_image_upload_types | 1 | | 19 | 2015_12_09_195748_add_user_avatars | 1 | | 20 | 2016_01_11_210908_add_external_auth_to_users | 1 | | 21 | 2016_02_25_184030_add_slug_to_revisions | 1 | | 22 | 2016_02_27_120329_update_permissions_and_roles | 1 | | 23 | 2016_02_28_084200_add_entity_access_controls | 1 | | 24 | 2016_03_09_203143_add_page_revision_types | 1 | | 25 | 2016_03_13_082138_add_page_drafts | 1 | | 26 | 2016_03_25_123157_add_markdown_support | 1 | | 27 | 2016_04_09_100730_add_view_permissions_to_roles | 1 | | 28 | 2016_04_20_192649_create_joint_permissions_table | 1 | | 29 | 2016_05_06_185215_create_tags_table | 1 | | 30 | 2016_07_07_181521_add_summary_to_page_revisions | 1 | | 31 | 2016_09_29_101449_remove_hidden_roles | 1 | | 32 | 2016_10_09_142037_create_attachments_table | 1 | | 33 | 2017_01_21_163556_create_cache_table | 1 | | 34 | 2017_01_21_163602_create_sessions_table | 1 | | 35 | 2017_03_19_091553_create_search_index_table | 1 | | 36 | 2017_04_20_185112_add_revision_counts | 1 | | 37 | 2017_07_02_152834_update_db_encoding_to_ut8mb4 | 1 | | 38 | 2017_08_01_130541_create_comments_table | 1 | | 39 | 2017_08_29_102650_add_cover_image_display | 1 | | 40 | 2018_07_15_173514_add_role_external_auth_id | 1 | | 41 | 2018_08_04_115700_create_bookshelves_table | 1 | | 42 | 2019_07_07_112515_add_template_support | 1 | | 43 | 2019_08_17_140214_add_user_invites_table | 1 | | 44 | 2019_12_29_120917_add_api_auth | 1 | | 45 | 2020_08_04_111754_drop_joint_permissions_id | 1 | | 46 | 2020_08_04_131052_remove_role_name_field | 1 | | 47 | 2020_09_19_094251_add_activity_indexes | 1 | | 48 | 2020_09_27_210059_add_entity_soft_deletes | 1 | | 49 | 2020_09_27_210528_create_deletions_table | 1 | | 50 | 2020_11_07_232321_simplify_activities_table | 1 | | 51 | 2020_12_30_173528_add_owned_by_field_to_entities | 1 | | 52 | 2021_01_30_225441_add_settings_type_column | 2 | | 53 | 2021_03_08_215138_add_user_slug | 2 | | 54 | 2021_05_15_173110_create_favourites_table | 3 | | 55 | 2021_06_30_173111_create_mfa_values_table | 4 | | 56 | 2021_07_03_085038_add_mfa_enforced_to_roles_table | 4 | | 57 | 2021_08_28_161743_add_export_role_permission | 4 | | 58 | 2021_09_26_044614_add_activities_ip_column | 5 | | 59 | 2021_11_26_070438_add_index_for_user_ip | 6 | | 60 | 2021_12_07_111343_create_webhooks_table | 7 | | 61 | 2021_12_13_152024_create_jobs_table | 7 | | 62 | 2021_12_13_152120_create_failed_jobs_table | 7 | | 63 | 2022_01_03_154041_add_webhooks_timeout_error_columns | 7 | | 64 | 2022_04_17_101741_add_editor_change_field_and_permission | 8 | | 65 | 2022_04_25_140741_update_polymorphic_types | 8 | | 66 | 2022_07_16_170051_drop_joint_permission_type | 9 | | 67 | 2022_08_17_092941_create_references_table | 10 | | 68 | 2022_09_02_082910_fix_shelf_cover_image_types | 10 | | 69 | 2022_10_07_091406_flatten_entity_permissions_table | 10 | +----+----------------------------------------------------------+-------+ 69 rows in set (0.00 sec) ``` </details> This is probably related to #3714, but I'm not getting the same error and the other issue is closed. Since all previous migrations were applied correctly, I'm opening a bug report. ### Browser Details N/A ### Exact BookStack Version 23.01 ### PHP Version 8.1 ### Hosting Environment Using docker.io/linuxserver/bookstack:version-v23.01
OVERLORD added the 🐛 Bug label 2026-02-05 06:51:49 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 1, 2023):

Hi @bendem,
This indicates there would have been another underlying error upon the initial upgrade & use of a v22.10 version of BookStack. Will be hard to find the issue/cause at this stage though.
Might need some manual database massaging since it looks like you hit an error part-way through a database migration during that v22.10 upgrade.

Hows your database knowledge/skill/comfort?

@ssddanbrown commented on GitHub (Feb 1, 2023): Hi @bendem, This indicates there would have been another underlying error upon the initial upgrade & use of a v22.10 version of BookStack. Will be hard to find the issue/cause at this stage though. Might need some manual database massaging since it looks like you hit an error part-way through a database migration during that v22.10 upgrade. Hows your database knowledge/skill/comfort?
Author
Owner

@bendem commented on GitHub (Feb 1, 2023):

Hm, it's a problem if a previous migration silently failed. I'll have to make sure our automations parse logs to avoid those errors from cropping up too late when context about what went wrong is gone.

If this is indeed a previous migration that has gone wrong, this issue can be closed, there is nothing to fix in bookstack. I just wanted to make sure it was reported if it was indeed a problem in the newer migrations.

Hows your database knowledge/skill/comfort?

I'm fairly proficient. I'm currently perusing through the migrations to see what could have gone wrong. I should be able to resolve it on my own by adding the missing columns until the migrations succeed.

@bendem commented on GitHub (Feb 1, 2023): Hm, it's a problem if a previous migration silently failed. I'll have to make sure our automations parse logs to avoid those errors from cropping up too late when context about what went wrong is gone. If this is indeed a previous migration that has gone wrong, this issue can be closed, there is nothing to fix in bookstack. I just wanted to make sure it was reported if it was indeed a problem in the newer migrations. > Hows your database knowledge/skill/comfort? I'm fairly proficient. I'm currently perusing through the migrations to see what could have gone wrong. I should be able to resolve it on my own by adding the missing columns until the migrations succeed.
Author
Owner

@ssddanbrown commented on GitHub (Feb 1, 2023):

I should be able to resolve it on my own by adding the missing columns until the migrations succeed.

Based on the current error, The failure would have been fairly far along before failure.
Can only think it failed on one of these lines. Might be easier/better to drop the restricted column from those mentioned tables manually (If existing). Then add a 2022_10_08_104202_drop_entity_restricted_field entry to the migrations table with a batch number of 11, based on your original table output provided above.

@ssddanbrown commented on GitHub (Feb 1, 2023): > I should be able to resolve it on my own by adding the missing columns until the migrations succeed. Based on the current error, The failure would have been fairly far along before failure. Can only think it failed [on one of these lines](https://github.com/BookStackApp/BookStack/blob/813d1402133160e08e35c86652df7d268765a6b9/database/migrations/2022_10_08_104202_drop_entity_restricted_field.php#L57-L59). Might be easier/better to drop the `restricted` column from those mentioned tables manually (If existing). Then add a `2022_10_08_104202_drop_entity_restricted_field` entry to the migrations table with a `batch` number of 11, based on your original table output provided above.
Author
Owner

@bendem commented on GitHub (Feb 3, 2023):

In the end I did that and it worked fine, I'll be reviewing the previous migrations to find the previous migration that didn't fully go through and make sure our database is not missing a part of a migration.

Thanks for the quick help, it was very helpful!

@bendem commented on GitHub (Feb 3, 2023): In the end I did that and it worked fine, I'll be reviewing the previous migrations to find the previous migration that didn't fully go through and make sure our database is not missing a part of a migration. Thanks for the quick help, it was very helpful!
Author
Owner

@bendem commented on GitHub (Feb 3, 2023):

I don't think I have lost much. The column that was missing comes from here (2016), but the next table created is restrictions, later renamed to entity_permissions, and that table exists in my DB. I guess I'll just live with the fact that a column was missing and I don't know where it went. 🤷‍♂️

@bendem commented on GitHub (Feb 3, 2023): I don't think I have lost much. The column that was missing comes from [here (2016)](https://github.com/BookStackApp/BookStack/blob/813d1402133160e08e35c86652df7d268765a6b9/database/migrations/2016_02_28_084200_add_entity_access_controls.php#L30-L33), but the next table created is `restrictions`, later renamed to `entity_permissions`, and that table exists in my DB. I guess I'll just live with the fact that a column was missing and I don't know where it went. 🤷‍♂️
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3485