Issue with yarn database:migrate:prod on version 0.43 β duplicate key value error
Hey everyone,
I'm encountering an error while running the migration for version 0.43 with the following command:
yarn database:migrate:prod
Error Message: QueryFailedError: duplicate key value violates unique constraint "IndexOnNameObjectMetadataIdAndWorkspaceIdUnique"
Key (name, "objectMetadataId", "workspaceId")=(body, afd4a320-c752-43e2-a7ce-74bf2b4b84f9, a1efc3dc-e551-44bd-bf80-b053f3af3ada) already exists.
Is there a known fix for this duplicate key issue in 0.43?
I had the error on production and also locally. Using the postgres image and the twenty-postgres:v0.32 image.
Thanks in advance for your help! π24 Replies
Hi! So you are in 0.42 and you are following https://twenty.com/developers/section/self-hosting/upgrade-guide#v0.42.0-to-v0.43.0 ?
Can you tell me the name of the objectMetadata having the id afd4a320-c752-43e2-a7ce-74bf2b4b84f9 ?
Thank you Thomast and sorry for my late respond. I got no notification. Yes, and I was doing option 2. The Name is "note".
Hi @berrylu, did you manage to perform the migration?
Unfortunately not, I am also having the same trouble with it on another instance :/
in your fielmetadata table, do we agree you only have one object named
body
associated with objectMetadataId afd4a320-c752-43e2-a7ce-74bf2b4b84f9
?
I don't get why the command tries to create a new field@thomast yes, there is only one entry for
When I go through all entries where "objectMetadataId" matches the uuid above, there is also one entry named "bodyV2". But this is fine right?
Yes this is fine. Could you please go to your DB and tell me:
- in the schema core, _typeorm_migrations table, what's the name of the last migration that has been run?
- same with the schema metadata, _typeorm_migrations
Thank you thomast, helping me. I am currently on my dev environment getting the same error. So we can try things without problems first. These are the returned data sets
ok I see nothing related
@Etienne would you know anything about it? I see a commit that may be intended for fixing this https://github.com/twentyhq/twenty/commit/258025a18f5d5ada8dd57c03cb1544870b270ede
GitHub
Fix upgrade-0-42 command to migrate RICH_TEXT field metadata to RIC...
β¦TEXT_V2 (#10218)
While making sure the upgrade-0.42 command was working as expected to
upgrade from 0.41 to 0.42, we've detected that the standardId of the new
bodyV2 (type RICH_TEXT_V2...
my bad this is @charles one
reminder @charles
Hi @berrylu, could you ping me in DM, let's schedule a call to fix the issue
same issue with body and bodyV2 duplicates. I assume that prevented a proper upgrade script and now I'm waiting on 0.42.9 while I manage something. If you guys solve that issue please let me know!
Could you please share your logs ?
Also your issue might be resolved in latest 0.42 patch I remember you've modified richtextv2 migration commands in these
Please always do a backup before trying to upgrade
@dialnco
Hi Charles, I was not able to reach you via DM. Are you ok with having a call at some pleasant time for you to fix the issue? I want to continue upgrading Twenty to recent versions soon π
Hello @berrylu unfortunately you're now on an pretty old Twenty version.
Are you facing the very same error than on 10 march ?
Yes it's the same error :/ haven't changed anything since then.
Do you have any backup from 0.42 ? If yes please try upgrading using the latest 0.43 patch version
Okay, I can create a backup first and try it then. I will try it asap. Thank you for now π
Sounds good ! Be aware that you cannot downgrade an twenty instance
@Prastoin Unfortunately I got the same error π¦ QueryFailedError: duplicate key value violates unique constraint "IndexOnNameObjectMetadataIdAndWorkspaceIdUnique" The name of the objectMetadata is "Open Record In"
@prastoin @charles Interesting, I have now upgraded to 0.42.18 first and after that upgraded to 0.43.5. The first issue upgrading to 0.43.5 was that it has not found the "update" command. Instead I ran
yarn command:prod upgrade-0.43
and now I get these errors instead:
[UpdateDefaultViewRecordOpeningOnWorkflowObjectsCommand] Error in workspace 334cfdc6-6566-42cc-a2f0-4b73c216f1e6 - Property "openRecordIn" was not found in "view". Make sure your query is correct.
Do you have an idea? I really want to get back to an updated state π¦ Good thing is that I can always activate my old backup. So I can try things easily.Hello @berrylu
was that it has not found the "update" commandThere's not update command, you're looking for
upgrade-X
Good thing you have a backup !
Unfortunately you're working with a pretty old version of twenty
Depending on the complexity of your twenty instance I would recommend exporting all you records and reimport them in a fresh latest twenty version@prastoin Unfortunately, I have a lot of attachments etc. So exporting would be a big hussle. Is there no way to delete the records in the db or something?
I have now manually migrated to v1. That was a day of work π’ But now its all working π Thank you!
You're the best ! Congrats ! feel free to reach out if you face any issues