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
This commit is contained in:
@ -15,13 +15,27 @@ export class RemoveUselessServerlessFunctionColumn1748942397538
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (metadataSchemaExists && metadataSchemaExists.length > 0) {
|
if (metadataSchemaExists && metadataSchemaExists.length > 0) {
|
||||||
await queryRunner.query(`
|
const potentialTypeNameToMigrate = [
|
||||||
ALTER TYPE "metadata"."dataSource_type_enum" SET SCHEMA "core";
|
'dataSource_type_enum',
|
||||||
ALTER TYPE "metadata"."indexMetadata_indextype_enum" SET SCHEMA "core";
|
'indexMetadata_indextype_enum',
|
||||||
ALTER TYPE "metadata"."relationMetadata_ondeleteaction_enum" SET SCHEMA "core";
|
'relationMetadata_ondeleteaction_enum',
|
||||||
ALTER TYPE "metadata"."serverlessFunction_syncstatus_enum" SET SCHEMA "core";
|
'serverlessFunction_syncstatus_enum',
|
||||||
|
] as const;
|
||||||
|
|
||||||
`);
|
for (const typeName of potentialTypeNameToMigrate) {
|
||||||
|
const selectResult = await queryRunner.query(
|
||||||
|
`SELECT 1 FROM information_schema.types WHERE type_schema = 'metadata' AND type_name = '${typeName}';`,
|
||||||
|
);
|
||||||
|
const typeNameExists = selectResult && selectResult.length > 0;
|
||||||
|
|
||||||
|
if (!typeNameExists) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TYPE "metadata"."${typeName}" SET SCHEMA "core";`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`DROP TYPE "core"."serverlessFunction_syncstatus_enum"`,
|
`DROP TYPE "core"."serverlessFunction_syncstatus_enum"`,
|
||||||
|
|||||||
Reference in New Issue
Block a user