Compare commits

...

2 Commits

Author SHA1 Message Date
Paul Rastoin 9e8939a85f UpdateServerless migration fix 2 (#12755)
closes
https://github.com/twentyhq/twenty/issues/12651#issuecomment-2990255291
2025-06-20 11:37:26 +02:00
Paul Rastoin e704ddc1ca Protect serverless migration metadata operations interacting with metadata (#12739)
# Introduction

This migration has been introduced in 0.54 we should determine how we
wanna handle retro-compatibility with this, might not wanna merge this
one latest main 🤔 but only a new 0.54 patch

related to
https://github.com/twentyhq/twenty/issues/12651#issuecomment-2988164122

## Concerns
If a workspace fails this migration that's not a good sign, the metadata
schema should be completely empty since 0.54 `metadata` merge into
`core` migration.
Please review you existing entries in the schema and verify they exists
in the dest `core` one
2025-06-19 17:18:59 +02:00
@@ -15,13 +15,27 @@ export class RemoveUselessServerlessFunctionColumn1748942397538
);
if (metadataSchemaExists && metadataSchemaExists.length > 0) {
await queryRunner.query(`
ALTER TYPE "metadata"."dataSource_type_enum" SET SCHEMA "core";
ALTER TYPE "metadata"."indexMetadata_indextype_enum" SET SCHEMA "core";
ALTER TYPE "metadata"."relationMetadata_ondeleteaction_enum" SET SCHEMA "core";
ALTER TYPE "metadata"."serverlessFunction_syncstatus_enum" SET SCHEMA "core";
`);
const potentialTypeNameToMigrate = [
'dataSource_type_enum',
'indexMetadata_indextype_enum',
'relationMetadata_ondeleteaction_enum',
'serverlessFunction_syncstatus_enum',
] as const;
for (const typeName of potentialTypeNameToMigrate) {
const selectResult = await queryRunner.query(
`SELECT true FROM pg_type WHERE typname = '${typeName}' AND typnamespace = 'metadata'::regnamespace`,
);
const typeNameExists = selectResult && selectResult.length > 0;
if (!typeNameExists) {
continue;
}
await queryRunner.query(
`ALTER TYPE "metadata"."${typeName}" SET SCHEMA "core";`,
);
}
}
await queryRunner.query(
`DROP TYPE "core"."serverlessFunction_syncstatus_enum"`,