Migration error v4 to v5 isValid()

Hi, I’m getting this error in my laravel.log while trying to migrate my data.

production.ERROR: Call to a member function isValid() on null {“userId”:1,“exception”:"[object] (Error(code: 0): Call to a member function isValid() on null at /home/myserveruser/public_html/invoiceninja/app/Http/Controllers/MigrationController.php:211)

After submitting the form on v4, I get : “Migration has started. We’ll update you with status, on your company e-mail.” Email never comes.

Thanks.

Hey,

Thanks for reporting this to us. Looks like v5 is not able to access your migration files.

Let’s first check if your v4 migration files are generated correctly.

Open invoiceninja v4 directory & navigate to storage/migrations and there you should see your migration files (zip archives). Are they vailid archives? Can you open them?

Thanks!

Hi!
Yeah, I can open it and see the migration.json file.
But there is nothing else in there.

Okay, that explains a lot. Can you tell me what version of Invoice Ninja are you running? Also, today we published a new version so you may try upgrading & trying again:

I tried updating without luck. I still get the same error even on 4.5.22.

Could it be because I installed invoiceninja via Softaculous in the first place?
But I since exported my data and moved to my own server where I installed it with the zip file…

All right, I’m gonna try to export migrations on my own instance & will let you know :+1:

Hi !
I’ve got the exact same error trying to migrate (same error in laravel.log and email never comes).
In /storage/mirgations/ the zip file contain a json file that has just a “true” string inside.
I’m on v4.5.22 and 5.0.25-26
Regards

I have the same issue with the same versions as @xxc. I also posted more here:

This issue should be resolve now. You may need to update your V4 Code to the latest from the master branch… and also your V5 code from the latest in the V5-develop branch.

1 Like

I’ll try right away and report back.

Should I clear some caches? With what commands?

Thanks.

EDIT :
I’ve got no errors on V5 log but nothing is happening.

I see the migration.zip file in my v4 storage. It is containing only a migration.json file.

Is there a link to manually trigger a migration on the v5 side?

Hey @stefgou,

Can you check your logs? They’re located in “storage/logs/laravel.log”. Also, do you have QUEUE_CONNECTION in the .env file and if so, what’s value of it?

Thanks!

Hi,
Nothing in the logs since 2 days.
I have queue_connection=database.

I’ll try to wipe everything and start brand new on v4 and v5.

Hey @ben
here’s an update…

I restarted from scratch. v4 and v5.

Created only one invoice in v4. Installed v5. Tried to migrate. Still nothing.

No error log in v5 laravel.
A directory was created inside v5 storage/migration with the same name as the zip in my v4 directory. But this new v5 directory was empty. No zip file inside.

If I copy the ZIP file to the new directory, how can I trigger the migration?

@stefgou are you running the latest code from v5-develop branch? there are fixes in there for this.

That was indeed the issue for me, hopefully it works for others. I was running the v5-stable branch. After pulling the v5-develop, the migration worked. (I never got an email notification as suggested, but all data is there, balances check out, and no errors in the log.)

1 Like

Yeah I have all the latest versions.

It seems like the migration is happening on the v4 side… then the task is scheduled on the v5 side… but when it runs, I get this error in the laravel.log

production.ERROR: ZipArchive::extractTo(): Invalid or uninitialized Zip object {"userId":1,"exception":"[object] (ErrorException(code: 0): ZipArchive::extractTo(): Invalid or uninitialized Zip object at /home/stepynny/public_html/invoiceninja/app/Jobs/Util/StartMigration.php:97)

Also, there is a directory that is created in v5 storage/migration.
But the directory is empty. Should the migration zip file be in there and that is throwing the above error?

In V5 there should be a zip file in storage/migrations.

Double check file / folder permissions.

On V4, ensure the code is up to date with Master, there are recent fixes.

I think I might have found a bug while looking at the ‘jobs’ table in my database.

{s:38:\"\u0000App\\Jobs\\Util\\StartMigration\u0000filepath\";s:130:\"\/home\/my_user\/public_html\/invoiceninja\/storage\/app\/public\/migrations\/gaqy5wplcp9ezafqszzblotn6e4crlhp-2020-11-29-invoiceninja.zip\"

As you can see, it looks for the file inside the “storage/app/public/migrations” directory.

Shouldn’t it be “storage/migrations” ?

If I manually make the change inside the database, and run “php artisan queue:listen”, it seems to find the zip file but I get this error:

production.ERROR: unserialize(): Error at offset 223 of 993 bytes {"exception":"[object] 
(ErrorException(code: 0): unserialize(): Error at offset 223 of 993 bytes at /home/my_user/public_html/invoiceninja/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:229)

Just to let you know that the fixes in 5.0.31 allowed me to migrate my data.

In PhpMyAdmin, I see the tables populated with my old v4 data.

Only problem, it looks like I can’t refresh my browser to show the data. All my invoices, clients, expenses are empty. I tried clicking on refresh data in the settings. Log out/Log in. Php artisan optimize. And more…

Is there something I need to run in the commande line?

@stefgou

When you migrate, it creates a new company, you’ll want to switch to your company in the top left hand corner of the UI, can you switch between the different companies.