Forum

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

New Discussion

Error after upgrade to 2.1.14

Mark Rhyne   ( User )

Commented 2 years ago

This code in app/Listeners/Update/V21/Version2114.php is not adding the tables 'I think', also why the "(preg_match('/"'s?


public function updateMediaTables()
{
$company_ids = [];

foreach (Media::withTrashed()->withoutGlobalScope(Company::class)->cursor() as $media) {
$company_id = null;

if (preg_match('/\d{4}(\/\d{2}){2}\/(\d+)\//', $media->directory, $matches) && isset($matches[2])) { // 2021/04/09/34235/invoices
$company_id = $matches[2];
} elseif (preg_match('/^(\d+)\//', $media->directory, $matches) && isset($matches[1])) { // 34235/invoices
$company_id = $matches[1];
}

if (null === $company_id) {
continue;
}

$company_ids[$company_id][] = $media->id;
}

foreach ($company_ids as $company_id => $media_ids) {
DB::table('media')->whereIn('id', $media_ids)->update(['company_id' => $company_id]);
DB::table('mediables')->whereIn('media_id', $media_ids)->update(['company_id' => $company_id]);
}

Schema::table('media', function (Blueprint $table) {
$table->unsignedInteger('company_id')->default(null)->change();
});

Schema::table('mediables', function (Blueprint $table) {
$table->unsignedInteger('company_id')->default(null)->change();
});
}

Skullmasher   ( User )

Commented 2 years ago

SOLVED the 500 for my case. Here's steps you can follow to solve the issue.

1. Make a backup of your database and your non working instalation specifically your .env file
2. Verify that APP_URL is defined in .env file located at the base of your akaunting instalation on you server: APP_URL=https://my-akaunting-url.com/
2. In the 500 error page verify that your version is 2.1.14 like in this screenshot https://i.imgur.com/VPwxMYY.png
3. If not on 2.1.14 unzip this into your install directory: https://github.com/akaunting/akaunting/releases/download/2.1.14/Akaunting_2.1.14-Stable.zip
4. I needed to add the the missing tables and column. Open your terminal and place yourself to to the base directory of your akaunting instalation using the cd command. Then run the migration to add the media and mediables missing tables by running this command: php artisan migrate. If something went wrong you can rollback using: php artisan migrate:rollback
5. After enabling the debug mode I found out I did not had the deleted_at column to the media tables. I created a migration file that add this column. Download this file: https://gist.github.com/SkullMasher/ffff9e85577a080536af0848fc3350ed. Place this in the database/migrations folder of your akaunting install and run php artisan migrate.
6. Refresh your page and PROFIT !

Thanks to the other contributor in this thread. I hope this helped. I can finally go to bed. Cheers

Tim Eden   ( User )

Commented 2 years ago

Thanks Skullmasher but still not working for me. When I try the migrate I get:

Migrating: 2016_06_27_000001_create_mediable_test_tables

In Connection.php line 678:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'izm_sample_mediables' already exists (SQL: create table `izm_sample_mediables` (`id` int unsigned not null auto_increment primary ke
y, `created_at` timestamp null, `updated_at` timestamp null, `deleted_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB ROW_FORMAT=DYNAMIC)


In Connection.php line 471:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'izm_sample_mediables' already exists

Tim Eden   ( User )

Commented 2 years ago

Actually, @Jake Day's solution appears to have worked for me though...

"The issue is in the migration script run while updating. To get it working after the upgrade, just add the company_id column to both your media and mediables table and you should be good to go."

Mark Rhyne   ( User )

Commented 2 years ago

After unziping and uploading https://github.com/akaunting/akaunting/releases/download/2.1.14/Akaunting_2.1.14-Stable.zip
I had to use /phpmyadmin as 'php artisan migrate' command would not accept.

Finding the Akaunting database file.
Then selecting the [/] "???_media" row using the [+]
then clicked on the [+] to expand Columns to expose the 'New' option, selecting that then:-

Fill in :
[Name] company_id
[Type] INT
[Length/Values] 10
[Attributes] UNSIGNED
leaving the others at their defaults

do the same for
???_mediables

And then it worked.

Thank-you everyone above. Someone should put the bug up on github.

Jake Day   ( User )

Commented 2 years ago

Glad I could help!

Web Treasurer   ( User )

Commented 2 years ago

Same problem, and @Jake Day's solution worked for me, as well. Thank you Jake!

Denis Dulici   ( Admin )

Commented 2 years ago

How did you guys update Akaunting? From the interface or docker or anything else?

Denis Dulici   ( Admin )

Commented 2 years ago

How did you guys update Akaunting? From the interface or docker or anything else?

Pedro   ( User )

Commented 2 years ago

Denis, I can't update here. (2.1.13 to 2.1.15)

https://ibb.co/F4WxmxR

Please login or register to leave a response.

Showing 21 to 30 of 38 discussions