T
Twenty2mo ago
Reptilon

[SELF HOST] "Metadata version not found for workspace" after failed version upgrade

I had Twenty v0.51.13 installed on a server. I tried to upgrade to v1.1 by following the procedure: going one major version at a time. However, it stopped working fine after v0.54. I tried a roll-back to v0.51.13 using my initial database backup, but now and after many tries, I cannot login anymore. I keep having the "Metadata version not found for workspace". I already tried flushing the cache, syncing the metadata, etc... I'm lost now.
30 Replies
Prastoin
Prastoin2mo ago
Hello at what version are you stuck right now ? Normally this a cache flush issue Does restoring your initial backup results to a functional instance ?
Reptilon
ReptilonOP2mo ago
Hi 👋🏻 , I'm at version v0.51.13. Restoring the initial backup didn't help. I've tried
yarn command:prod cache:flush
yarn command:prod cache:flush
multiple times with no luck.
Prastoin
Prastoin2mo ago
Have you restarted your containers/pods ?
Reptilon
ReptilonOP2mo ago
Yes I've done
docker compose down
docker compose down
and
docker compose up -d
docker compose up -d
too
Prastoin
Prastoin2mo ago
Could you please share your cache flush logs ? Just to be sure you're restoring the 0.51.13 dump on the same twenty instance isn't ?
Reptilon
ReptilonOP2mo ago
Yes I do
Reptilon
ReptilonOP2mo ago
Here are the logs:
Prastoin
Prastoin2mo ago
No problem here Please remove any remaining volumes using docker compose down -v be careful this is a destructive opération ( keep your dump file )
Reptilon
ReptilonOP2mo ago
So I should stop, remove and build again?
Prastoin
Prastoin2mo ago
Adding the --volumes or -v flag will delete any existing volumes This flag has to be added to the down command In a nutshell remove and stop at the same time
Reptilon
ReptilonOP2mo ago
Ok, should I pull data from the backup again now ?
Prastoin
Prastoin2mo ago
After deleting the volumes yes you will to restore the backup
Reptilon
ReptilonOP2mo ago
Ok I've done that. Now I have the "You're not a member of this workspace" error Probably related:
ERROR: duplicate key value violates unique constraint "PK_a6ff2a8e8bb563f3d15635efd01"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY _typeorm_migrations, line 1
ERROR: insert or update on table "appToken" violates foreign key constraint "FK_d6ae19a7aa2bbd4919053257772"
DETAIL: Key (workspaceId)=(7693e8c1-599f-48c5-a464-1f8a6d2c7d11) is not present in table "workspace".
COPY 0
ERROR: insert or update on table "featureFlag" violates foreign key constraint "FK_6be7761fa8453f3a498aab6e72b"
DETAIL: Key (workspaceId)=(7693e8c1-599f-48c5-a464-1f8a6d2c7d11) is not present in table "workspace".
COPY 0
COPY 0
COPY 0
COPY 2
ERROR: insert or update on table "userWorkspace" violates foreign key constraint "FK_22f5e76f493c3fb20237cfc48b0"
DETAIL: Key (workspaceId)=(7693e8c1-599f-48c5-a464-1f8a6d2c7d11) is not present in table "workspace".
COPY 1
COPY 0
ERROR: duplicate key value violates unique constraint "PK_a6ff2a8e8bb563f3d15635efd01"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY _typeorm_migrations, line 1
COPY 1
ERROR: insert or update on table "fieldMetadata" violates foreign key constraint "FK_de2a09b9e3e690440480d2dee26"
DETAIL: Key (objectMetadataId)=(d4fd61cf-ae49-455d-991d-a8dcb2f1c799) is not present in table "objectMetadata".
ERROR: duplicate key value violates unique constraint "PK_a6ff2a8e8bb563f3d15635efd01"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY _typeorm_migrations, line 1
ERROR: insert or update on table "appToken" violates foreign key constraint "FK_d6ae19a7aa2bbd4919053257772"
DETAIL: Key (workspaceId)=(7693e8c1-599f-48c5-a464-1f8a6d2c7d11) is not present in table "workspace".
COPY 0
ERROR: insert or update on table "featureFlag" violates foreign key constraint "FK_6be7761fa8453f3a498aab6e72b"
DETAIL: Key (workspaceId)=(7693e8c1-599f-48c5-a464-1f8a6d2c7d11) is not present in table "workspace".
COPY 0
COPY 0
COPY 0
COPY 2
ERROR: insert or update on table "userWorkspace" violates foreign key constraint "FK_22f5e76f493c3fb20237cfc48b0"
DETAIL: Key (workspaceId)=(7693e8c1-599f-48c5-a464-1f8a6d2c7d11) is not present in table "workspace".
COPY 1
COPY 0
ERROR: duplicate key value violates unique constraint "PK_a6ff2a8e8bb563f3d15635efd01"
DETAIL: Key (id)=(1) already exists.
CONTEXT: COPY _typeorm_migrations, line 1
COPY 1
ERROR: insert or update on table "fieldMetadata" violates foreign key constraint "FK_de2a09b9e3e690440480d2dee26"
DETAIL: Key (objectMetadataId)=(d4fd61cf-ae49-455d-991d-a8dcb2f1c799) is not present in table "objectMetadata".
Prastoin
Prastoin2mo ago
Are you restoring a backup of 0.55 or your latest instance?
Reptilon
ReptilonOP2mo ago
backup of latest instance core.workspace.version is 0.51.13 in my backup
Prastoin
Prastoin2mo ago
Unfortunately it seems like your dump is corrupted due to migration involved in upgrading to the latest version Do you have any other backup available ?
Reptilon
ReptilonOP2mo ago
No I don't. Is there any chance to at least recover companies and contacts information I have in my backup? I can try to install a fresh V1.1 Up 🙌🏻 new ideas?
Prastoin
Prastoin2mo ago
Yes totally You can extract them using the csv export and re-import them in an latest instance Please find similar dilemma https://github.com/twentyhq/twenty/issues/13174#event-18641829645
Reptilon
ReptilonOP2mo ago
Thanks, will give it a try and keep you posted I managed to get it back to work on a v0.51.14 fresh install. I'll try to upgrade one version at a time again.
Prastoin
Prastoin2mo ago
Congrats ! Please be sure to save a dump a dump before doing so
Reptilon
ReptilonOP2mo ago
When trying to go from v0.51.14 to v0.52.11, I got the following error message after:
command:prod upgrade
command:prod upgrade
Cannot read properties of null (reading 'fromObjectMetadataId')
Prastoin
Prastoin2mo ago
please share the whole logs especially the line prefix
Reptilon
ReptilonOP2mo ago
Here you go:
[Nest] 426 - 07/17/2025, 10:02:41 AM LOG [MigrateRelationsToFieldMetadataCommand] Running command for workspace 7693e8c1-599f-48c5-a464-1f8a6d2c7d11 1/1
[Nest] 426 - 07/17/2025, 10:02:42 AM WARN [MigrateRelationsToFieldMetadataCommand] Error in workspace 7693e8c1-599f-48c5-a464-1f8a6d2c7d11: Cannot read properties of null (reading 'fromObjectMetadataId')
[Nest] 426 - 07/17/2025, 10:02:42 AM ERROR [MigrateRelationsToFieldMetadataCommand] Error in workspace 7693e8c1-599f-48c5-a464-1f8a6d2c7d11: Cannot read properties of null (reading 'fromObjectMetadataId')
[Nest] 426 - 07/17/2025, 10:02:42 AM ERROR [MigrateRelationsToFieldMetadataCommand] undefined
[Nest] 426 - 07/17/2025, 10:02:42 AM LOG [MigrateRelationsToFieldMetadataCommand] Command completed!
[Nest] 426 - 07/17/2025, 10:02:41 AM LOG [MigrateRelationsToFieldMetadataCommand] Running command for workspace 7693e8c1-599f-48c5-a464-1f8a6d2c7d11 1/1
[Nest] 426 - 07/17/2025, 10:02:42 AM WARN [MigrateRelationsToFieldMetadataCommand] Error in workspace 7693e8c1-599f-48c5-a464-1f8a6d2c7d11: Cannot read properties of null (reading 'fromObjectMetadataId')
[Nest] 426 - 07/17/2025, 10:02:42 AM ERROR [MigrateRelationsToFieldMetadataCommand] Error in workspace 7693e8c1-599f-48c5-a464-1f8a6d2c7d11: Cannot read properties of null (reading 'fromObjectMetadataId')
[Nest] 426 - 07/17/2025, 10:02:42 AM ERROR [MigrateRelationsToFieldMetadataCommand] undefined
[Nest] 426 - 07/17/2025, 10:02:42 AM LOG [MigrateRelationsToFieldMetadataCommand] Command completed!
Reptilon
ReptilonOP2mo ago
As you sggested in another post, I manually deleted the problematic relations. However, I have now this error:
Prastoin
Prastoin2mo ago
It seems like a command is not idempotent I would recommend restoring the backup, removing the problematic relation row, and then upgrade
Reptilon
ReptilonOP2mo ago
Can you elaborate further please ? Which problematic relation should I remove ?
Prastoin
Prastoin2mo ago
As you sggested in another post, I manually deleted the problematic relations. However, I have now this error:
1/ Restore 0.52.14 backup in an 0.51.14 twenty instance 2/ " I manually deleted the problematic relations." 3/ Upgrade
Reptilon
ReptilonOP2mo ago
I gave up. I installed v1.1.1 and will manually fill in back the data. RIP and thanks for your support. Hope it will never happen again
Prastoin
Prastoin2mo ago
Sorry to hear that, you can import data as csv to fasten things up
Reptilon
ReptilonOP2mo ago
Yep

Did you find this page helpful?