T
Twentyβ€’4w 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! πŸ™
12 Replies
thomast
thomastβ€’4w 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β€’3w 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β€’2w ago
Hi @berrylu, did you manage to perform the migration?
berrylu
berryluOPβ€’2w ago
Unfortunately not, I am also having the same trouble with it on another instance :/
thomast
thomastβ€’2w 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β€’2w 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β€’7d 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β€’7d 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β€’7d ago
ok I see nothing related
thomast
thomastβ€’7d 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β€’3d ago
my bad this is @charles one reminder @charles
charles
charlesβ€’23h ago
Hi @berrylu, could you ping me in DM, let's schedule a call to fix the issue

Did you find this page helpful?