Upgrade issue to 0.22

Running on my test server to see if upgrade process from 0.11 to 0.22 During start of containers a migration is run automatically so I assume migrate is not needed anymore so I am not running yarn database:migrate:prod manually anymore when i first run workspace-sync i receive an error (see comment, too long message) then I run command:prod upgrade-0.22 it also receives error:
[Nest] 519 - 08/01/2024, 10:56:31 AM LOG [UpdateMessageChannelSyncStageEnumCommand] Running command on workspace 75f6e77a-ec52-43fd-af2b-5e1ca8319b2e failed
[Nest] 519 - 08/01/2024, 10:56:31 AM ERROR [UpdateMessageChannelSyncStageEnumCommand] Migration failed for workspace 75f6e77a-ec52-43fd-af2b-5e1ca8319b2e: type "workspace_6zezc5oiagj6yqldcepfgb226.messageChannel_syncStage_enum" does not exist
[Nest] 519 - 08/01/2024, 10:56:31 AM LOG [UpdateMessageChannelSyncStageEnumCommand] Command completed
[Nest] 519 - 08/01/2024, 10:56:31 AM LOG [UpdateMessageChannelSyncStageEnumCommand] Running command on workspace 75f6e77a-ec52-43fd-af2b-5e1ca8319b2e failed
[Nest] 519 - 08/01/2024, 10:56:31 AM ERROR [UpdateMessageChannelSyncStageEnumCommand] Migration failed for workspace 75f6e77a-ec52-43fd-af2b-5e1ca8319b2e: type "workspace_6zezc5oiagj6yqldcepfgb226.messageChannel_syncStage_enum" does not exist
[Nest] 519 - 08/01/2024, 10:56:31 AM LOG [UpdateMessageChannelSyncStageEnumCommand] Command completed
if I then run workspace-sync again it works and then I can run command:prod upgrade-0.22 again without error followed up with workspace-sync without error. Is this expected behaviour or is there a better way then just "rerun both commands twice"? I noticed that if I run
yarn command:prod upgrade-0.22:fix-object-metadata-id-standard-id
yarn command:prod upgrade-0.22:fix-object-metadata-id-standard-id
before running workspace-sync i seem to get around this "run twice" behaviour, is this the/a correct solution?
15 Replies
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
error: error: duplicate key value violates unique constraint "IndexOnNameObjectMetadataIdAndWorkspaceIdUnique"
Sync of standard objects failed with: QueryFailedError: duplicate key value violates unique constraint "IndexOnNameObjectMetadataIdAndWorkspaceIdUnique"
at PostgresQueryRunner.query (/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async InsertQueryBuilder.execute (/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
at async SubjectExecutor.executeInsertOperations (/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
at async SubjectExecutor.execute (/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
at async EntityPersistExecutor.execute (/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
at async WorkspaceMetadataUpdaterService.updateFieldMetadata (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-metadata-updater.service.js:89:48)
at async WorkspaceSyncFieldMetadataService.synchronize (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-field-metadata.service.js:49:44)
at async WorkspaceSyncMetadataService.synchronize (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service.js:63:46)
at async SyncWorkspaceMetadataCommand.run (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.js:66:58)
error: error: duplicate key value violates unique constraint "IndexOnNameObjectMetadataIdAndWorkspaceIdUnique"
Sync of standard objects failed with: QueryFailedError: duplicate key value violates unique constraint "IndexOnNameObjectMetadataIdAndWorkspaceIdUnique"
at PostgresQueryRunner.query (/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async InsertQueryBuilder.execute (/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
at async SubjectExecutor.executeInsertOperations (/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
at async SubjectExecutor.execute (/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
at async EntityPersistExecutor.execute (/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:140:21)
at async WorkspaceMetadataUpdaterService.updateFieldMetadata (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-metadata-updater.service.js:89:48)
at async WorkspaceSyncFieldMetadataService.synchronize (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-field-metadata.service.js:49:44)
at async WorkspaceSyncMetadataService.synchronize (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/workspace-sync-metadata.service.js:63:46)
at async SyncWorkspaceMetadataCommand.run (/app/packages/twenty-server/dist/src/engine/workspace-manager/workspace-sync-metadata/commands/sync-workspace-metadata.command.js:66:58)
charles
charlesβ€’4mo ago
Hi @πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄, to migrate to 0.22 from 0.11, you would need to go through each minor versions This can be a bit challenging, please ping me in DM and send me your dump and I can do that for you πŸ™‚ Still working on providing smooth upgrades but things move fast and it's hard to keep track of it
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
So that would be 0.12 0.20 and 0.22? Does 0.12 have any similar commands to upgrade-0.22? I think I saw upgrade-0.20 If possible i'd rather just script the "real upgrade" instead of dumping and fixing it on a dump I ran through all the upgrades instead and it worked out much better in the end. Thank you for your suggestion. Thank you @charles
charles
charlesβ€’4mo ago
so all good? πŸ™‚
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
Yes, going through the different versions and also running the fix commands available in those versions (for examle "upgrade-0.22:fix-object-metadata-id-standard-id" ) made it smooth. I basically: 1. Start with Dockerimage of version+1 2. migrate 3. ran fix commands 4. ran forced workspace-sync 5. Checked health and if not v0.22 then goto 1
charles
charlesβ€’4mo ago
That's great! As the project stabilize, we might be able to upgrade without going through all versions but for now that's the best we can do without slowing too much the process ; we always make sure that we can smoothly upgrade from a minor version to the next one
mnbro
mnbroβ€’4mo ago
How can I find out which are the fix commands for a specific version? @charles When you say " we always make sure that we can smoothly upgrade from a minor version to the next one" how can I check the the upgrade process went smoothly ---- is there any command that returns the status of migration?
mnbro
mnbroβ€’4mo ago
For example I raised this issue on Github: https://github.com/twentyhq/twenty/issues/6187 when trying to update from 0.20 to 0.21 and it didn't work out. This is why I'm trying to find out about how can I safely upgrade from one version to another(also before 0.21) and how can I make sure everything went smootly
GitHub
No TimeLine Events Β· Issue #6187 Β· twentyhq/twenty
Hi, For all v0.21.x of twentycrm for Any selected object there is No Event in TimeLine. I think is related to this: GraphQLError:relation "workspace_1tijfbhq4kpru5g3bwbr1anui.calendarEvent&quo...
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
I looked for them in src/packages/twenty/database. There is a workspace health command to check health and workspace sync command that should be run as well (to my understanding) I can send you my ansible script when I'm back at work (on mobile now so path above is only roughly correct from memory)
mnbro
mnbroβ€’4mo ago
Thank you!
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
From what I understand @charles please correct me if I'm wrong. There are 3 major parts of upgrading. 1. DB migration which updates the meta data structure 2. Workspace sync which makes sure your database matches the meta data structure 3. Various fix commands that correct issues that came from earlier versions that can't be part of the above structure 1. is automatic by environment variable but can be run manually. 2. needs to be run manually on upgrade 3. Needs to be run "sometimes" depending on data from earlier versions. When issues are found they are added so the fix i mentioned was added in 0.21.x to correct, I assume, an issue that was found during 0.21.x being latest version There are definetly details I'm missing but this is my current outsider perspective
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
@mnbro Here is the part of my ansible script that is looped over with different versions to upgrade
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
These fix commands was most likely not ALL needed but I did not feel the need to eliminate which ones were redundant since they donΒ΄t exactly break anything either.
mnbro
mnbroβ€’4mo ago
@πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄ I have no words that could describe my appreciation for your help! Thank you very much!
πŸ…ΉπŸ…°πŸ†ˆπŸ…±πŸ…΄πŸ…΄
Do remind yourself that I'm a clueless user and everything I say is based on flawed assumptions, guesswork and reading documentation & code
Want results from more Discord servers?
Add your server