twenty
twenty copied to clipboard
Add unique indexes and indexes for composite types
Add support for indexes on composite fields and unicity constraint on indexes
This pull request includes several changes across multiple files to improve error handling, enforce unique constraints, and update database migrations. The most important changes include updating error messages for snack bars, adding a new command to enforce unique constraints, and updating database migrations to include new fields and constraints.
Error Handling Improvements:
-
packages/twenty-front/src/modules/error-handler/components/PromiseRejectionEffect.tsx
: Updated error messages inenqueueSnackBar
to useerror.message
directly. -
packages/twenty-front/src/modules/object-metadata/hooks/useFindManyObjectMetadataItems.ts
: Simplified error messages inenqueueSnackBar
. -
packages/twenty-front/src/modules/object-record/hooks/useFindDuplicateRecords.ts
: Simplified error messages inenqueueSnackBar
. -
packages/twenty-front/src/modules/object-record/hooks/useHandleFindManyRecordsError.ts
: Simplified error messages inenqueueSnackBar
.
New Command for Unique Constraints:
-
packages/twenty-server/src/database/commands/upgrade-version/0-31/0-31-enforce-unique-constraints.command.ts
: Added a new command to enforce unique constraints on company domain names and person emails. -
packages/twenty-server/src/database/commands/upgrade-version/0-31/0-31-upgrade-version.command.ts
: Integrated the newEnforceUniqueConstraintsCommand
into the upgrade process. [1] [2] [3] -
packages/twenty-server/src/database/commands/upgrade-version/0-31/0-31-upgrade-version.module.ts
: Registered the newEnforceUniqueConstraintsCommand
in the module. [1] [2]
Database Migrations:
-
packages/twenty-server/src/database/typeorm/metadata/migrations/1726757368824-migrationDebt.ts
: Added a migration to update therelationMetadata_ondeleteaction_enum
and set default values. -
packages/twenty-server/src/database/typeorm/metadata/migrations/1726757368825-addIsUniqueToIndexMetadata.ts
: Added a migration to include theisUnique
field inindexMetadata
. -
packages/twenty-server/src/database/typeorm/metadata/migrations/1726762935841-addCompostiveColumnToIndexFieldMetadata.ts
: Added a migration to include thecompositeColumn
field inindexFieldMetadata
. -
packages/twenty-server/src/database/typeorm/metadata/migrations/1726766871572-addWhereToIndexMetadata.ts
: Added a migration to include theindexWhereClause
field inindexMetadata
.
GraphQL Exception Handling:
-
packages/twenty-server/src/engine/api/graphql/workspace-query-runner/utils/workspace-query-runner-graphql-api-exception-handler.util.ts
: Enhanced exception handling forQueryFailedError
to provide more specific error messages for unique constraint violations. [1] [2] -
packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/create-many-resolver.factory.ts
: Updated theworkspaceQueryRunnerGraphqlApiExceptionHandler
call to include context. -
packages/twenty-server/src/engine/api/graphql/workspace-resolver-builder/factories/create-one-resolver.factory.ts
: Updated theworkspaceQueryRunnerGraphqlApiExceptionHandler
call to include context.