Skip to content

The open alternative to Salesforce, designed for AI.

Add missing migration for unaccent (#14566)

Félix Malfaitfda3183ba64c
diff --git a/packages/twenty-server/src/database/typeorm/core/migrations/common/1758117800000-activate-unaccent-extension.ts b/packages/twenty-server/src/database/typeorm/core/migrations/common/1758117800000-activate-unaccent-extension.ts
new file mode 100644
index 00000000000..d5116924551
--- /dev/null
+++ b/packages/twenty-server/src/database/typeorm/core/migrations/common/1758117800000-activate-unaccent-extension.ts
@@ -0,0 +1,25 @@
+import { type MigrationInterface, type QueryRunner } from 'typeorm';
+
+export class ActivateUnaccentExtension1758117800000
+ implements MigrationInterface
+{
+ name = 'ActivateUnaccentExtension1758117800000';
+
+ public async up(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "unaccent"`);
+
+ await queryRunner.query(
+ `CREATE OR REPLACE FUNCTION unaccent_immutable(text) RETURNS text AS $$
+ SELECT public.unaccent($1)
+ $$ LANGUAGE sql IMMUTABLE;`,
+ );
+ }
+
+ public async down(queryRunner: QueryRunner): Promise<void> {
+ await queryRunner.query(`DROP FUNCTION IF EXISTS unaccent_immutable(text)`);
+
+ // Note: We don't drop the extension as it might be used by other parts
+ // Note: We don't drop the extension as it might be used by other parts
+ // of the application or other databases. Extensions are typically left in place.
+ }
+}