chore(core): Remove md5 usage for user id generation in postgres (#21687)

This commit is contained in:
Andreas Fitzek 2025-11-11 12:18:32 +01:00 committed by GitHub
parent 13b7fa5c68
commit 8aed72ffb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import type { IrreversibleMigration, MigrationContext } from '../migration-types';
/**
* PostgreSQL-specific migration to change the default value for the `id` column in `user` table.
* The previous default implementation was based on MD5 hashing to produce a random UUID, but
* MD5 is not supported in FIPS compliant postgres environments. We are switching to `gen_random_uuid()`
* which is supported in versions of PostgreSQL since 13.
*/
export class ChangeDefaultForIdInUserTable1762771264000 implements IrreversibleMigration {
async up({ queryRunner, escape }: MigrationContext) {
const tableName = escape.tableName('user');
const idColumnName = escape.columnName('id');
await queryRunner.query(
`ALTER TABLE ${tableName} ALTER COLUMN ${idColumnName} SET DEFAULT gen_random_uuid()`,
);
}
}

View File

@ -111,6 +111,7 @@ import { DropUnusedChatHubColumns1760965142113 } from '../common/1760965142113-D
import { AddWorkflowDescriptionColumn1762177736257 } from '../common/1762177736257-AddWorkflowDescriptionColumn';
import { BackfillMissingWorkflowHistoryRecords1762763704614 } from '../common/1762763704614-BackfillMissingWorkflowHistoryRecords';
import type { Migration } from '../migration-types';
import { ChangeDefaultForIdInUserTable1762771264000 } from './1762771264000-ChangeDefaultForIdInUserTable';
export const postgresMigrations: Migration[] = [
InitialMigration1587669153312,
@ -225,4 +226,5 @@ export const postgresMigrations: Migration[] = [
AddWorkflowDescriptionColumn1762177736257,
CreateOAuthEntities1760116750277,
BackfillMissingWorkflowHistoryRecords1762763704614,
ChangeDefaultForIdInUserTable1762771264000,
];