T
Twentyβ€’7mo ago
berrylu

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
thomast
thomastβ€’7mo ago
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 ?
berrylu
berryluOPβ€’7mo ago
Thank you Thomast and sorry for my late respond. I got no notification. Yes, and I was doing option 2. The Name is "note".
thomast
thomastβ€’6mo ago
Hi @berrylu, did you manage to perform the migration?
berrylu
berryluOPβ€’6mo ago
Unfortunately not, I am also having the same trouble with it on another instance :/
thomast
thomastβ€’6mo ago
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
berrylu
berryluOPβ€’6mo ago
@thomast yes, there is only one entry for
SELECT * FROM metadata."fieldMetadata"
WHERE "objectMetadataId" = 'afd4a320-c752-43e2-a7ce-74bf2b4b84f9' AND "name" = 'body'
ORDER BY id ASC
SELECT * FROM metadata."fieldMetadata"
WHERE "objectMetadataId" = 'afd4a320-c752-43e2-a7ce-74bf2b4b84f9' AND "name" = 'body'
ORDER BY id ASC
When I go through all entries where "objectMetadataId" matches the uuid above, there is also one entry named "bodyV2". But this is fine right?
thomast
thomastβ€’6mo ago
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
berrylu
berryluOPβ€’6mo ago
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
thomast
thomastβ€’6mo ago
ok I see nothing related
thomast
thomastβ€’6mo ago
@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...
thomast
thomastβ€’6mo ago
my bad this is @charles one reminder @charles
charles
charlesβ€’6mo ago
Hi @berrylu, could you ping me in DM, let's schedule a call to fix the issue
dialnco
dialncoβ€’6mo ago
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!
Prastoin
Prastoinβ€’6mo ago
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
berrylu
berryluOPβ€’4mo ago
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 πŸ™‚
Prastoin
Prastoinβ€’4mo ago
Hello @berrylu unfortunately you're now on an pretty old Twenty version. Are you facing the very same error than on 10 march ?
berrylu
berryluOPβ€’4mo ago
Yes it's the same error :/ haven't changed anything since then.
Prastoin
Prastoinβ€’4mo ago
Do you have any backup from 0.42 ? If yes please try upgrading using the latest 0.43 patch version
berrylu
berryluOPβ€’4mo ago
Okay, I can create a backup first and try it then. I will try it asap. Thank you for now πŸ™‚
Prastoin
Prastoinβ€’4mo ago
Sounds good ! Be aware that you cannot downgrade an twenty instance
berrylu
berryluOPβ€’3mo ago
@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.
Prastoin
Prastoinβ€’3mo ago
Hello @berrylu
was that it has not found the "update" command
There'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
berrylu
berryluOPβ€’3mo ago
@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!
Prastoin
Prastoinβ€’3mo ago
You're the best ! Congrats ! feel free to reach out if you face any issues

Did you find this page helpful?