500: Server Error on export

I’m urgently trying to run an export so I can restore the data on a new server installation.
But when I run the export a 500: Server Error pops up.
I’m running V5.2.2 (shared hosting - Siteground) setup as a sub domain.
When I try and run an-up-date, it says that the update completed but then this error message appears.

Fatal error : Uncaught Error: Call to a member function connection() on null in /home/customer/www/ninja.sitename.co.za/public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Schema.php:45 Stack trace: #0 /home/customer/www/ninja.sitename.co.za/public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(166): Illuminate\Support\Facades\Schema::getFacadeAccessor() #1 /home/customer/www/ninja.sitename.co.za/public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(255): Illuminate\Support\Facades\Facade::getFacadeRoot() #2 /home/customer/www/ninja.sitename.co.za/public_html/app/Exceptions/Handler.php(100): Illuminate\Support\Facades\Facade::__callStatic(‘hasTable’, Array) #3 /home/customer/www/ninja.sitename.co.za/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(414): App\Exceptions\Handler->report(Object(RuntimeException)) #4 /home/customer/www/ninja.sitename.co.za/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php in /home/customer/www/ninja.sitename.co.za/public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Schema.php on line 45

I know that the latest version of Invoice ninja works with php 8.1.21 which I then enabled and when I try and refresh the page I get a whole lot of depreciated messages.

This is an error message that pulled from the laravel log

[2023-07-26 09:26:08] production.ERROR: ZipArchive::close(): Failure to create temporary file: No such file or directory {“userId”:1,“exception”:"[object] (ErrorException(code: 0): ZipArchive::close(): Failure to create temporary file: No such file or directory at /home/customer/www/ninja.sitename.co.za/public_html/app/Jobs/Company/CompanyExport.php:496)
[stacktrace]
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, ‘ZipArchive::clo…’, ‘/home/customer/…’, 496, Array)

I proceeded to restore a backup to the original working version V5.2.2 and do a manual over write with version V5.3.100 which allows me to login but when I run the export again the 500: Server Error pops up again.

any assistance would be appreciated

Hi,

Those are very old versions, you may want to try manually copying over the latest release (currently v5.6.22).

Note: there are two ways to export data in the app: using the export option on Settings > Import/Export or using the export option in the reports.

Hi There

So the export option from reports section will allow me to import into a new install and version of Invoice ninja and retain the data? I will just have to manually re build the settings that were used in the old version?

If you’re transferring data to a new install we recommend using mysqldump. If the versions are the same you can use the JSON export/import but it doesn’t include activity/history.

So what would the process be of performing a successful mysqldump. Run a myssqldump on the old V5.2.2 and restore on the latest version of invoice ninja on a new server?

Yes, that is correct

Hi
So I have exported a copy of the db from the old server and trying to restore it on the new server copy and im getting all sorts of mysql errors on importing of the BD.
I had a #1062 and fixed that and then after that a #1452 error still battling to restore the data.
Is there a process that I need to follow to make sure that the mysqldump is clean before importing it back into the db of the new server install?

@david do you have any suggestions?

These error indicate duplicates in the dataset?

If you are exporting via mysqldump and importing via the same, this would all be related to those tools.

Hi Guys
So I’m exporting the old db and what do I need to do from here?
Do I setup a clean db once i have installed the new version on the new server and import the old db data into the clean db, because if I do this then I still get the 500: server error when trying to login via the new server install with the imported data in a clean db.
Or do I need to import old db into the db that was created with the new install on new server?

@ninjasa

How are you exporting the database?

After the export, you just need to create a blank db, and then reimport the database into the new one.

If you are successfully restoring the database, then you’ll want to inspect the logs to understand the 500 error message.

I’m exporting via phpMyAdmin
Yes I created a blank DB imported old DB which was successful and changed the .env file to point to new db with imported data.
Where do I find the logs to see the error message for 500: Server Error ?
are there no encryption or tokens in the db data that needs to be deleted?

error im seeing in laravel.log

[2023-07-27 09:44:36] production.ERROR: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘u815756910_ninja.purchase_orders’ doesn’t exist (SQL: select * from purchase_orders where purchase_orders.company_id in (3, 6) and created_at >= 1970-01-01 00:00:00) {“userId”:1,“exception”:"[object] (Illuminate\Database\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘u815756910_ninja.purchase_orders’ doesn’t exist (SQL: select * from purchase_orders where purchase_orders.company_id in (3, 6) and created_at >= 1970-01-01 00:00:00) at /home/u815756910/domains/sitename.co.za/public_html/ninja/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760)
[stacktrace]

[previous exception] [object] (PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘u815756910_ninja.purchase_orders’ doesn’t exist at /home/u815756910/domains/sitename.co.za/public_html/ninja/vendor/laravel/framework/src/Illuminate/Database/Connection.php:414)
[stacktrace]

enabled debug mode and this is the message i get when trying to login

500: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘u815756910_ninja.purchase_orders’ doesn’t exist (SQL: select * from purchase_orders where purchase_orders.company_id in (3, 6) and created_at >= 1970-01-01 00:00:00)

It may help to run php artisan migrate to create any missing database tables/fields.

Ok, do you have any info on how I would go about running this command?

You would need to SSH into the server and then run this command from the CLI in the root folder of the project.

This is the error message i get when running the php artisan migrate command via ssh

2021_08_23_101529_recurring_expenses_schema … 5ms FAIL

In Connection.php line 760:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘recurring_e
xpenses’ already exists (SQL: create table recurring_expenses (id int u
nsigned not null auto_increment primary key, created_at timestamp(6) null
, updated_at timestamp(6) null, deleted_at timestamp null, company_id
int unsigned not null, vendor_id int unsigned null, user_id int unsign
ed not null, status_id int unsigned not null, invoice_id int unsigned n
ull, client_id int unsigned null, bank_id int unsigned null, project_i d int unsigned null, payment_type_id int unsigned null, recurring_expen se_id int unsigned null, is_deleted tinyint(1) not null default ‘0’, us es_inclusive_taxes tinyint(1) not null default ‘1’, tax_name1 varchar(19

  1. null, tax_name2 varchar(191) null, tax_name3 varchar(191) null, dat e date null, payment_date date null, should_be_invoiced tinyint(1) not
    null default ‘0’, invoice_documents tinyint(1) not null default ‘0’, tr ansaction_id varchar(191) null, custom_value1 varchar(191) null, custom _value2 varchar(191) null, custom_value3 varchar(191) null, custom_valu e4 varchar(191) null, category_id int unsigned null, calculate_tax_by_a mount tinyint(1) not null default ‘0’, tax_amount1 decimal(20, 6) null,
    tax_amount2 decimal(20, 6) null, tax_amount3 decimal(20, 6) null, tax_ rate1 decimal(20, 6) null, tax_rate2 decimal(20, 6) null, tax_rate3 de
    cimal(20, 6) null, amount decimal(20, 6) null, foreign_amount decimal(2
    0, 6) null, exchange_rate decimal(20, 6) not null default ‘1’, assigned_ user_id int unsigned null, number varchar(191) null, invoice_currency_i d int unsigned null, currency_id int unsigned null, private_notes text
    null, public_notes text null, transaction_reference text null, freque ncy_id int unsigned not null, last_sent_date datetime null, next_send_d ate datetime null, remaining_cycles int null) default character set utf8
    mb4 collate ‘utf8mb4_unicode_ci’ engine = InnoDB)

In Connection.php line 545:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘recurring_e
xpenses’ already exists

Hi guys any further suggestions on sorting this issue?

@david do you have any thoughts?