Skip to content

Impossible to update on several instances (tables already existing error) #5995

@LoosGuccreen

Description

@LoosGuccreen

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hello, I have 3 instances of bookstack and can't seem to update any of them. Two are on v23.02.2 and one is on v25.02.4.

When I try to update, during the php artisan migrate part, I get errors that tables already exists:

on v23:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'imports' already exists (SQL: create table `imports` (`id` int un  
  signed not null auto_increment primary key, `name` varchar(191) not null, `path` varchar(191) not null, `size` int not null, `typ  
  e` varchar(191) not null, `metadata` longtext not null, `created_by` int not null, `created_at` timestamp null, `updated_at` time  
  stamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')     

on v25:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'entities' already exists (Connection: mysql, SQL: create table `entities` (`id` bi  
  gint unsigned not null auto_increment, `type` varchar(10) not null, `name` varchar(191) not null, `slug` varchar(191) not null, `book_id` bigint u  
  nsigned null, `chapter_id` bigint unsigned null, `priority` int unsigned null, `created_at` timestamp null, `updated_at` timestamp null, `deleted_  
  at` timestamp null, `created_by` int unsigned null, `updated_by` int unsigned null, `owned_by` int unsigned null, primary key (`id`, `type`)) defa  
  ult character set utf8mb4 collate 'utf8mb4_unicode_ci')      

On the v23.02.2 instances, I get this error for tables watches, import and sort_rules . If I drop those tables (they are empty anyway) the update performs but is broken with this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'activities.entity_id' in 'where clause' (SQL: select * from `activities` where (exists (select `entity_id`, `entity_type`, max(owner_id) as owner_id, max(status) as status from `joint_permissions` where `activities`.`entity_id` = `joint_permissions`.`entity_id` and `role_id` in (1) and `activities`.`entity_type` = `joint_permissions`.`entity_type` group by `entity_type`, `entity_id` having (status IN (1, 3) or (owner_id = 1 and status != 2)))) and (`entity_type` != page or exists (select `id` from `pages` where `pages`.`id` = `activities`.`entity_id` and `activities`.`entity_type` = page and `pages`.`draft` = 0)) order by `created_at` desc limit 10 offset 0)

If I try to manually add the column entity_id and entity_type in the activities table then the issue seems to be fixed but tbh I don't think I can trust such patches (also I just guessed their type as INT and VARCHAR but I have no idea what's supposed to be and if there's supposed to be a default value in it or what...)

On the v25.02.4 the error is for the table entities and I stopped there because there are important datas in this table.

I don't think I did anything shady with these installs and I have no idea why I get these errors… any help would be welcome (I'm fine with doing a clean install if there's a way to save the databases and migrate them but I don't know how to do that).

Thanks a lot!

Exact BookStack Version

v23.02.2 and v25.02.4

Log Content

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'activities.entity_id' in 'where clause' (SQL: select * from `activities` where (exists (select `entity_id`, `entity_type`, max(owner_id) as owner_id, max(status) as status from `joint_permissions` where `activities`.`entity_id` = `joint_permissions`.`entity_id` and `role_id` in (1) and `activities`.`entity_type` = `joint_permissions`.`entity_type` group by `entity_type`, `entity_id` having (status IN (1, 3) or (owner_id = 1 and status != 2)))) and (`entity_type` != page or exists (select `id` from `pages` where `pages`.`id` = `activities`.`entity_id` and `activities`.`entity_type` = page and `pages`.`draft` = 0)) order by `created_at` desc limit 10 offset 0)
#0 /(…)/vendor/laravel/framework/src/Illuminate/Database/Connection.php(720): Illuminate\Database\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1 /(…)/vendor/laravel/framework/src/Illuminate/Database/Connection.php(405): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure))
#2 /(…)/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2705): Illuminate\Database\Connection->select('select * from `...', Array, true)
#3 /(…)/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2694): Illuminate\Database\Query\Builder->runSelect()
#4 /(…)/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3230): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#5 /(…)/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2693): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#6 /(…)/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(710): Illuminate\Database\Query\Builder->get(Array)
#7 /(…)/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(694): Illuminate\Database\Eloquent\Builder->getModels(Array)
#8 /(…)/app/Actions/ActivityQueries.php(34): Illuminate\Database\Eloquent\Builder->get()
#9 /(…)/app/Http/Controllers/HomeController.php(24): BookStack\Actions\ActivityQueries->latest(10)
#10 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): BookStack\Http\Controllers\HomeController->index(Object(BookStack\Http\Request), Object(BookStack\Actions\ActivityQueries))
#11 /(…)/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\Routing\Controller->callAction('index', Array)
#12 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Route.php(259): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(BookStack\Http\Controllers\HomeController), 'index')
#13 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\Routing\Route->runController()
#14 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Router.php(798): Illuminate\Routing\Route->run()
#15 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(BookStack\Http\Request))
#16 /(…)/app/Http/Middleware/Authenticate.php(23): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#17 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): BookStack\Http\Middleware\Authenticate->handle(Object(BookStack\Http\Request), Object(Closure))
#18 /(…)/app/Http/Middleware/Localization.php(45): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#19 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): BookStack\Http\Middleware\Localization->handle(Object(BookStack\Http\Request), Object(Closure))
#20 /(…)/app/Http/Middleware/RunThemeActions.php(26): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#21 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): BookStack\Http\Middleware\RunThemeActions->handle(Object(BookStack\Http\Request), Object(Closure))
#22 /(…)/app/Http/Middleware/CheckEmailConfirmed.php(47): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#23 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): BookStack\Http\Middleware\CheckEmailConfirmed->handle(Object(BookStack\Http\Request), Object(Closure))
#24 /(…)/app/Http/Middleware/PreventAuthenticatedResponseCaching.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#25 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): BookStack\Http\Middleware\PreventAuthenticatedResponseCaching->handle(Object(BookStack\Http\Request), Object(Closure))
#26 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#27 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(BookStack\Http\Request), Object(Closure))
#28 /(…)/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#29 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(BookStack\Http\Request), Object(Closure))
#30 /(…)/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#31 /(…)/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(BookStack\Http\Request), Object(Illuminate\Session\Store), Object(Closure))
#32 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Session\Middleware\StartSession->handle(Object(BookStack\Http\Request), Object(Closure))
#33 /(…)/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#34 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(BookStack\Http\Request), Object(Closure))
#35 /(…)/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#36 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(BookStack\Http\Request), Object(Closure))
#37 /(…)/app/Http/Middleware/ApplyCspRules.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#38 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): BookStack\Http\Middleware\ApplyCspRules->handle(Object(BookStack\Http\Request), Object(Closure))
#39 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#40 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Router.php(797): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#41 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Router.php(776): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(BookStack\Http\Request))
#42 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Router.php(740): Illuminate\Routing\Router->runRoute(Object(BookStack\Http\Request), Object(Illuminate\Routing\Route))
#43 /(…)/vendor/laravel/framework/src/Illuminate/Routing/Router.php(729): Illuminate\Routing\Router->dispatchToRoute(Object(BookStack\Http\Request))
#44 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(190): Illuminate\Routing\Router->dispatch(Object(BookStack\Http\Request))
#45 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(BookStack\Http\Request))
#46 /(…)/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#47 /(…)/app/Http/Middleware/TrustProxies.php(41): Illuminate\Http\Middleware\TrustProxies->handle(Object(BookStack\Http\Request), Object(Closure))
#48 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): BookStack\Http\Middleware\TrustProxies->handle(Object(BookStack\Http\Request), Object(Closure))
#49 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#50 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(BookStack\Http\Request), Object(Closure))
#51 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(BookStack\Http\Request), Object(Closure))
#52 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#53 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(BookStack\Http\Request), Object(Closure))
#54 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#55 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(BookStack\Http\Request), Object(Closure))
#56 /(…)/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(BookStack\Http\Request))
#57 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#58 /(…)/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(134): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(BookStack\Http\Request))
#59 /(…)/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(BookStack\Http\Request))
#60 {main}

Hosting Environment

PHP 8.2.30, MySQL 5.7.32, Apache 2.4.51, shared hosting

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions