v22.07 "Duplicate column name 'template'" #2931

Closed
opened 2026-02-05 05:46:12 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @TheCDC on GitHub (Jul 29, 2022).

Describe the Bug

Environment

Docker image: lscr.io/linuxserver/bookstack
Bookstack version: v22.07

root@39396b2a00d4:/var/www/html# cat version 
v22.07

Error

Error occurs when running migrations. Migration 2019_07_07_112515_add_template_support fails with the following output.

root@39396b2a00d4:/var/www/html# php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migrating: 2019_07_07_112515_add_template_support

   Illuminate\Database\QueryException 

  SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'template' (SQL: alter table `pages` add `template` tinyint(1) not null default '0')

  at 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  database/migrations/2019_07_07_112515_add_template_support.php:20
      Illuminate\Support\Facades\Facade::__callStatic()

      +22 vendor frames
  33  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Docker compose snippet

  bookstack:
    image: lscr.io/linuxserver/bookstack
    container_name: bookstack
    labels:
      traefik.enable: "true"

      traefik.http.routers.bookstack.entrypoints: "websecure"
      traefik.http.routers.bookstack.rule: "Host(`docs.$DUCKDNS_DOMAIN`)"
      traefik.http.routers.bookstack.tls.certresolver: "myresolver"

      traefik.http.routers.bookstack-local.rule: "Host(`docs.localhost`)||(Host(`$IP_LOCAL`)  && PathPrefix(`/docs`))"

    environment:
      - PUID=1000
      - PGID=1000
      - APP_URL=http://docs.localhost
      - DB_HOST=bookstack_db
      - DB_USER=bookstack
      - DB_PASS=<...>
      - DB_DATABASE=bookstackapp
    volumes:
      - ./bookstackapp/config:/config
    restart: unless-stopped
    depends_on:
      - bookstack_db
  bookstack_db:
    image: lscr.io/linuxserver/mariadb
    container_name: bookstack_db
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=<...>
      - TZ=America/Los Angeles
      - MYSQL_DATABASE=bookstackapp
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=<...>
    volumes:
      - ./bookstack_db/config:/config
    restart: unless-stopped

Steps to Reproduce

  1. Instantiate a new container from the image lscr.io/linuxserver/bookstack.
  2. Open a shell into the image
  3. cd /var/www/html && php artisan migrate

Expected Behaviour

Expected behavior is that all migrations run without error.

Screenshots or Additional Context

php artisan migrate:status

root@39396b2a00d4:/var/www/html# php artisan migrate:status
+------+----------------------------------------------------------+-------+
| Ran? | Migration                                                | Batch |
+------+----------------------------------------------------------+-------+
| Yes  | 2014_10_12_000000_create_users_table                     | 1     |
| Yes  | 2014_10_12_100000_create_password_resets_table           | 1     |
| Yes  | 2015_07_12_114933_create_books_table                     | 1     |
| Yes  | 2015_07_12_190027_create_pages_table                     | 1     |
| Yes  | 2015_07_13_172121_create_images_table                    | 1     |
| Yes  | 2015_07_27_172342_create_chapters_table                  | 1     |
| Yes  | 2015_08_08_200447_add_users_to_entities                  | 1     |
| Yes  | 2015_08_09_093534_create_page_revisions_table            | 1     |
| Yes  | 2015_08_16_142133_create_activities_table                | 1     |
| Yes  | 2015_08_29_105422_add_roles_and_permissions              | 1     |
| Yes  | 2015_08_30_125859_create_settings_table                  | 1     |
| Yes  | 2015_08_31_175240_add_search_indexes                     | 1     |
| Yes  | 2015_09_04_165821_create_social_accounts_table           | 1     |
| Yes  | 2015_09_05_164707_add_email_confirmation_table           | 1     |
| Yes  | 2015_11_21_145609_create_views_table                     | 1     |
| Yes  | 2015_11_26_221857_add_entity_indexes                     | 1     |
| Yes  | 2015_12_05_145049_fulltext_weighting                     | 1     |
| Yes  | 2015_12_07_195238_add_image_upload_types                 | 1     |
| Yes  | 2015_12_09_195748_add_user_avatars                       | 1     |
| Yes  | 2016_01_11_210908_add_external_auth_to_users             | 1     |
| Yes  | 2016_02_25_184030_add_slug_to_revisions                  | 1     |
| Yes  | 2016_02_27_120329_update_permissions_and_roles           | 1     |
| Yes  | 2016_02_28_084200_add_entity_access_controls             | 1     |
| Yes  | 2016_03_09_203143_add_page_revision_types                | 1     |
| Yes  | 2016_03_13_082138_add_page_drafts                        | 1     |
| Yes  | 2016_03_25_123157_add_markdown_support                   | 1     |
| Yes  | 2016_04_09_100730_add_view_permissions_to_roles          | 1     |
| Yes  | 2016_04_20_192649_create_joint_permissions_table         | 1     |
| Yes  | 2016_05_06_185215_create_tags_table                      | 1     |
| Yes  | 2016_07_07_181521_add_summary_to_page_revisions          | 1     |
| Yes  | 2016_09_29_101449_remove_hidden_roles                    | 1     |
| Yes  | 2016_10_09_142037_create_attachments_table               | 1     |
| Yes  | 2017_01_21_163556_create_cache_table                     | 1     |
| Yes  | 2017_01_21_163602_create_sessions_table                  | 1     |
| Yes  | 2017_03_19_091553_create_search_index_table              | 1     |
| Yes  | 2017_04_20_185112_add_revision_counts                    | 1     |
| Yes  | 2017_07_02_152834_update_db_encoding_to_ut8mb4           | 1     |
| Yes  | 2017_08_01_130541_create_comments_table                  | 1     |
| Yes  | 2017_08_29_102650_add_cover_image_display                | 1     |
| Yes  | 2018_07_15_173514_add_role_external_auth_id              | 1     |
| Yes  | 2018_08_04_115700_create_bookshelves_table               | 1     |
| No   | 2019_07_07_112515_add_template_support                   |       |
| No   | 2019_08_17_140214_add_user_invites_table                 |       |
| No   | 2019_12_29_120917_add_api_auth                           |       |
| No   | 2020_08_04_111754_drop_joint_permissions_id              |       |
| No   | 2020_08_04_131052_remove_role_name_field                 |       |
| No   | 2020_09_19_094251_add_activity_indexes                   |       |
| No   | 2020_09_27_210059_add_entity_soft_deletes                |       |
| No   | 2020_09_27_210528_create_deletions_table                 |       |
| No   | 2020_11_07_232321_simplify_activities_table              |       |
| No   | 2020_12_30_173528_add_owned_by_field_to_entities         |       |
| No   | 2021_01_30_225441_add_settings_type_column               |       |
| No   | 2021_03_08_215138_add_user_slug                          |       |
| No   | 2021_05_15_173110_create_favourites_table                |       |
| No   | 2021_06_30_173111_create_mfa_values_table                |       |
| No   | 2021_07_03_085038_add_mfa_enforced_to_roles_table        |       |
| No   | 2021_08_28_161743_add_export_role_permission             |       |
| No   | 2021_09_26_044614_add_activities_ip_column               |       |
| No   | 2021_11_26_070438_add_index_for_user_ip                  |       |
| No   | 2021_12_07_111343_create_webhooks_table                  |       |
| No   | 2021_12_13_152024_create_jobs_table                      |       |
| No   | 2021_12_13_152120_create_failed_jobs_table               |       |
| No   | 2022_01_03_154041_add_webhooks_timeout_error_columns     |       |
| No   | 2022_04_17_101741_add_editor_change_field_and_permission |       |
| No   | 2022_04_25_140741_update_polymorphic_types               |       |
| No   | 2022_07_16_170051_drop_joint_permission_type             |       |
+------+----------------------------------------------------------+-------+

Browser Details

No response

Exact BookStack Version

v22.07

PHP Version

7.4.26

Hosting Environment

Windows 10, Docker, lscr.io/linuxserver/bookstack

Originally created by @TheCDC on GitHub (Jul 29, 2022). ### Describe the Bug # Environment Docker image: `lscr.io/linuxserver/bookstack` Bookstack version: v22.07 ``` root@39396b2a00d4:/var/www/html# cat version v22.07 ``` # Error Error occurs when running migrations. Migration `2019_07_07_112515_add_template_support` fails with the following output. ``` root@39396b2a00d4:/var/www/html# php artisan migrate ************************************** * Application In Production! * ************************************** Do you really wish to run this command? (yes/no) [no]: > yes Migrating: 2019_07_07_112515_add_template_support Illuminate\Database\QueryException SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'template' (SQL: alter table `pages` add `template` tinyint(1) not null default '0') at 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 database/migrations/2019_07_07_112515_add_template_support.php:20 Illuminate\Support\Facades\Facade::__callStatic() +22 vendor frames 33 artisan:37 Illuminate\Foundation\Console\Kernel::handle() ``` # Docker compose snippet ``` bookstack: image: lscr.io/linuxserver/bookstack container_name: bookstack labels: traefik.enable: "true" traefik.http.routers.bookstack.entrypoints: "websecure" traefik.http.routers.bookstack.rule: "Host(`docs.$DUCKDNS_DOMAIN`)" traefik.http.routers.bookstack.tls.certresolver: "myresolver" traefik.http.routers.bookstack-local.rule: "Host(`docs.localhost`)||(Host(`$IP_LOCAL`) && PathPrefix(`/docs`))" environment: - PUID=1000 - PGID=1000 - APP_URL=http://docs.localhost - DB_HOST=bookstack_db - DB_USER=bookstack - DB_PASS=<...> - DB_DATABASE=bookstackapp volumes: - ./bookstackapp/config:/config restart: unless-stopped depends_on: - bookstack_db bookstack_db: image: lscr.io/linuxserver/mariadb container_name: bookstack_db environment: - PUID=1000 - PGID=1000 - MYSQL_ROOT_PASSWORD=<...> - TZ=America/Los Angeles - MYSQL_DATABASE=bookstackapp - MYSQL_USER=bookstack - MYSQL_PASSWORD=<...> volumes: - ./bookstack_db/config:/config restart: unless-stopped ``` ### Steps to Reproduce 1. Instantiate a new container from the image `lscr.io/linuxserver/bookstack`. 2. Open a shell into the image 3. `cd /var/www/html && php artisan migrate` ### Expected Behaviour Expected behavior is that all migrations run without error. ### Screenshots or Additional Context # php artisan migrate:status ``` root@39396b2a00d4:/var/www/html# php artisan migrate:status +------+----------------------------------------------------------+-------+ | Ran? | Migration | Batch | +------+----------------------------------------------------------+-------+ | Yes | 2014_10_12_000000_create_users_table | 1 | | Yes | 2014_10_12_100000_create_password_resets_table | 1 | | Yes | 2015_07_12_114933_create_books_table | 1 | | Yes | 2015_07_12_190027_create_pages_table | 1 | | Yes | 2015_07_13_172121_create_images_table | 1 | | Yes | 2015_07_27_172342_create_chapters_table | 1 | | Yes | 2015_08_08_200447_add_users_to_entities | 1 | | Yes | 2015_08_09_093534_create_page_revisions_table | 1 | | Yes | 2015_08_16_142133_create_activities_table | 1 | | Yes | 2015_08_29_105422_add_roles_and_permissions | 1 | | Yes | 2015_08_30_125859_create_settings_table | 1 | | Yes | 2015_08_31_175240_add_search_indexes | 1 | | Yes | 2015_09_04_165821_create_social_accounts_table | 1 | | Yes | 2015_09_05_164707_add_email_confirmation_table | 1 | | Yes | 2015_11_21_145609_create_views_table | 1 | | Yes | 2015_11_26_221857_add_entity_indexes | 1 | | Yes | 2015_12_05_145049_fulltext_weighting | 1 | | Yes | 2015_12_07_195238_add_image_upload_types | 1 | | Yes | 2015_12_09_195748_add_user_avatars | 1 | | Yes | 2016_01_11_210908_add_external_auth_to_users | 1 | | Yes | 2016_02_25_184030_add_slug_to_revisions | 1 | | Yes | 2016_02_27_120329_update_permissions_and_roles | 1 | | Yes | 2016_02_28_084200_add_entity_access_controls | 1 | | Yes | 2016_03_09_203143_add_page_revision_types | 1 | | Yes | 2016_03_13_082138_add_page_drafts | 1 | | Yes | 2016_03_25_123157_add_markdown_support | 1 | | Yes | 2016_04_09_100730_add_view_permissions_to_roles | 1 | | Yes | 2016_04_20_192649_create_joint_permissions_table | 1 | | Yes | 2016_05_06_185215_create_tags_table | 1 | | Yes | 2016_07_07_181521_add_summary_to_page_revisions | 1 | | Yes | 2016_09_29_101449_remove_hidden_roles | 1 | | Yes | 2016_10_09_142037_create_attachments_table | 1 | | Yes | 2017_01_21_163556_create_cache_table | 1 | | Yes | 2017_01_21_163602_create_sessions_table | 1 | | Yes | 2017_03_19_091553_create_search_index_table | 1 | | Yes | 2017_04_20_185112_add_revision_counts | 1 | | Yes | 2017_07_02_152834_update_db_encoding_to_ut8mb4 | 1 | | Yes | 2017_08_01_130541_create_comments_table | 1 | | Yes | 2017_08_29_102650_add_cover_image_display | 1 | | Yes | 2018_07_15_173514_add_role_external_auth_id | 1 | | Yes | 2018_08_04_115700_create_bookshelves_table | 1 | | No | 2019_07_07_112515_add_template_support | | | No | 2019_08_17_140214_add_user_invites_table | | | No | 2019_12_29_120917_add_api_auth | | | No | 2020_08_04_111754_drop_joint_permissions_id | | | No | 2020_08_04_131052_remove_role_name_field | | | No | 2020_09_19_094251_add_activity_indexes | | | No | 2020_09_27_210059_add_entity_soft_deletes | | | No | 2020_09_27_210528_create_deletions_table | | | No | 2020_11_07_232321_simplify_activities_table | | | No | 2020_12_30_173528_add_owned_by_field_to_entities | | | No | 2021_01_30_225441_add_settings_type_column | | | No | 2021_03_08_215138_add_user_slug | | | No | 2021_05_15_173110_create_favourites_table | | | No | 2021_06_30_173111_create_mfa_values_table | | | No | 2021_07_03_085038_add_mfa_enforced_to_roles_table | | | No | 2021_08_28_161743_add_export_role_permission | | | No | 2021_09_26_044614_add_activities_ip_column | | | No | 2021_11_26_070438_add_index_for_user_ip | | | No | 2021_12_07_111343_create_webhooks_table | | | No | 2021_12_13_152024_create_jobs_table | | | No | 2021_12_13_152120_create_failed_jobs_table | | | No | 2022_01_03_154041_add_webhooks_timeout_error_columns | | | No | 2022_04_17_101741_add_editor_change_field_and_permission | | | No | 2022_04_25_140741_update_polymorphic_types | | | No | 2022_07_16_170051_drop_joint_permission_type | | +------+----------------------------------------------------------+-------+ ``` ### Browser Details _No response_ ### Exact BookStack Version v22.07 ### PHP Version 7.4.26 ### Hosting Environment Windows 10, Docker, lscr.io/linuxserver/bookstack
OVERLORD added the 🐛 Bug label 2026-02-05 05:46:12 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jul 29, 2022):

Hi @TheCDC,
This reflects an error/failure in the original migration run.

Since you're running on windows, I suspect you're running into the issues found in linuxserver/docker-bookstack/issues/125.
Look specifically to be an issue around how the database can't keep up with changes when used with a Windows volume mount.

@ssddanbrown commented on GitHub (Jul 29, 2022): Hi @TheCDC, This reflects an error/failure in the original migration run. Since you're running on windows, I suspect you're running into the issues found in linuxserver/docker-bookstack/issues/125. Look specifically to be an issue around how the database can't keep up with changes when used with a Windows volume mount.
Author
Owner

@TheCDC commented on GitHub (Jul 29, 2022):

@ssddanbrown Thank you! I don't know why I didn't find that issue but I agree this is a duplicate. I'll close mine out.

@TheCDC commented on GitHub (Jul 29, 2022): @ssddanbrown Thank you! I don't know why I didn't find that issue but I agree this is a duplicate. I'll close mine out.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2931