BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
14.91k stars 1.87k forks source link

SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table `roles` drop `name`) #2636

Closed csjjpm closed 2 years ago

csjjpm commented 3 years ago

When I do 'php artisan migrate' I get this error

Migrating: 2020_08_04_111754_drop_joint_permissions_id Migrated: 2020_08_04_111754_drop_joint_permissions_id (1.59 seconds) Migrating: 2020_08_04_131052_remove_role_name_field

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name)

at /usr/local/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) {

669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673|

csjjpm commented 3 years ago

If I create a blank database and import my SQL backup I get this error on the webpage. ' UnexpectedValueException The stream or file "/usr/local/www/BookStack/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied ' If I try the migrate command I get this error: '

yes

Migrating: 2020_08_04_111754_drop_joint_permissions_id Migrated: 2020_08_04_111754_drop_joint_permissions_id (2.14 seconds) Migrating: 2020_08_04_131052_remove_role_name_field

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name)

at /usr/local/www/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) {

669| throw new QueryException( '

ssddanbrown commented 3 years ago

Hi @csjjpm,

The stream or file "/usr/local/www/BookStack/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

This would indicate the webserver user does not have permission to write to the logs file when an error has occured. You'll need to review permissions set on the storage/, bootstap/cache and public/uploads folders.

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'name'; check that column/key exists (SQL: alter table roles drop name)

This would occur if you the migrations table has become out of sync with the database schema. Have you previously made manual edits to the database to get around previous errors? Or made edits to the migrations table at all?

csjjpm commented 3 years ago

Hi, I gave my www user full write access to those folders as per instructions.

I have not touched the database schema, I have made no manual changes.

Thanks Paul

csjjpm commented 3 years ago

Hi, although the folders had rwx the log file didn't. I have fixed that so the laravel.log error doesn't exist. Now I have this error after logging in.

Illuminate\Database\QueryException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'field list' (SQL: insert into `activities` (`type`, `user_id`, `detail`, `updated_at`, `created_at`) values (auth_login, 3, (3) Paul, 2021-03-18 08:19:07, 2021-03-18 08:19:07))
ssddanbrown commented 2 years ago

Since the last comment on this issue is relatively old I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.