Repository: twentyhq/twenty
File: packages/twenty-server/src/database/commands/upgrade-version-command/1-12/1-12-clean-null-equivalent-values.ts (TypeScript)

Code before:
                    const uniqueCompositeProperties =
                      compositeType.properties.filter(
                        (property) => property.isIncludedInUniqueConstraint,
                      );

                    return uniqueCompositeProperties.map((subField) =>
                      computeCompositeColumnName(fieldMetadata.name, subField),
                    );
                  }

                  return [fieldMetadata.name];
                },
              );

              const dropIndexAction: WorkspaceMigrationIndexAction = {
                action: WorkspaceMigrationIndexActionType.DROP,
                name: index.name,
                columns: [],
                isUnique: true,
              };

              const createIndexAction: WorkspaceMigrationIndexAction = {
                action: WorkspaceMigrationIndexActionType.CREATE,
                name: index.name,
                columns: columnNames,
                isUnique: true,
              };

              const migration: WorkspaceMigrationTableAction = {
                name: tableName,
                action: WorkspaceMigrationTableActionType.ALTER_INDEXES,
                indexes: [dropIndexAction, createIndexAction],
              };

              await this.workspaceMigrationService.createCustomMigration(
                generateMigrationName(
                  `update-index-${index.name}-remove-where`,
                ),
                workspaceId,
                [migration],
              );

              await this.workspaceMigrationRunnerService.executeMigrationFromPendingMigrations(
                workspaceId,
              );
            }
          }
        }
      }
    }
    if (!isDryRun) {

Review comment (suggestion):
***Remark:*** Was surprised by the new index payload, `where` is optional in new one which result in
```ts
where: null,
```

Code after:
              {
                workspaceId,
                flatMapsKeys: ['flatIndexMaps'],
              },
            );

            const columnNames = index.indexFieldMetadatas.flatMap(
              (indexFieldMetadata) => {
                const fieldMetadata = objectMetadataItem.fields.find(
                  (f) => f.id === indexFieldMetadata.fieldMetadataId,
                );

                if (!isDefined(fieldMetadata)) {
                  throw new Error(
                    `Field metadata not found for index field metadata ${indexFieldMetadata.id}`,
                  );
                }

                if (isCompositeFieldMetadataType(fieldMetadata.type)) {
                  const compositeType = compositeTypeDefinitions.get(
                    fieldMetadata.type,
                  ) as CompositeType;

                  const uniqueCompositeProperties =
                    compositeType.properties.filter(
                      (property) => property.isIncludedInUniqueConstraint,
                    );

                  return uniqueCompositeProperties.map((subField) =>
                    computeCompositeColumnName(fieldMetadata.name, subField),
                  );
                }

                return [fieldMetadata.name];
              },
            );

            const dropIndexAction: WorkspaceMigrationIndexAction = {
              action: WorkspaceMigrationIndexActionType.DROP,
              name: index.name,
              columns: [],
              isUnique: true,
            };

            const createIndexAction: WorkspaceMigrationIndexAction = {
              action: WorkspaceMigrationIndexActionType.CREATE,
              name: index.name,
              columns: columnNames,
              isUnique: true,
              where: null,
            };