Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

SQLSTATE[42000]: Syntax error or access violation

Tony Baker   ( User )

Commented 3 years ago

After I did upgrade from Akaunting 2.0.27 to 2.1.1 I've lost all Billings and Invoices (but they are available in DB) also Tax Summary showing 0.00

Here is the error:
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'akaunting_documents_document_number_deleted_at_company_id_type_unique' is too long (SQL: alter table `akaunting_documents` add unique `akaunting_documents_document_number_deleted_at_company_id_type_unique`(`document_number`, `deleted_at`, `company_id`, `type`)) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'akaunting_documents_document_number_deleted_at_company_id_type_unique' is too long (SQL: alter table `akaunting_documents` add unique `akaunting_documents_document_number_deleted_at_company_id_type_unique`(`document_number`, `deleted_at`, `company_id`, `type`)) at /var/www/akaunting/vendor/laravel/framework/src/Illuminate/Database/Connection.php:678)

I would highly appreciate the help here.

Tony Baker   ( User )

Commented 3 years ago

Hi everybody,

I found the solution, it was our mistake.
As you can see from the error log that our DB prefix calls "akaunting" which was a bad idea to use such a long prefix as we did. So the DB prefix was too long which was causing the problem. We only had to make the DB prefix less than or equal to 3 characters. (eg. aka_ instead akaunting_). More details here https://i.imgur.com/aGURHSo.jpg

Our apologies to Akaunting team for such a silly report, it is a really great application.

Tony Baker   ( User )

Commented 2 years ago

I face the same issue again trying to update from Version2.1.9 to 2.1.23. This time isn't a problem with my DB prefix. Seems that this always happens when you have a big gap between versions.

So it's problem in the way how Akaunting software updates, developers should think about this issue, not make Identifier Length more than 64 characters, if more tables need to be updated try to split it somehow.

If I try to update it gradually eg. from V2.1.9 to 2.1.10 and so on, that may fix this issue but I don't know how to do that. I did try this "php artisan update:finish core 1 2.1.10 2.1.9" but didn't work.

can anyone write here how to update Akaunting versions gradually, or have a resolution for this isue?

Please login or register to leave a response.

Showing 1 to 3 of 3 discussions