Skip to content

Conversation

@carbonFibreCode
Copy link
Contributor

migration command in response to the fix : #17529 for the issue twentyhq/core-team-issues#2027

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 29, 2026

Greptile Overview

Greptile Summary

This PR adds a data migration command to convert DATE_TIME field filter values from ISO datetime format (e.g., 2024-01-31T12:00:00Z) to plain date format (e.g., 2024-01-31) for filters using the IS operand. This migration addresses a fix made in PR #17529 that changed how the frontend stores DATE_TIME IS filter values.

The migration:

  • Queries all view filters for a workspace with their field metadata relation loaded
  • Filters to only process DATE_TIME fields with IS operand where the value contains 'T' (indicating old datetime format)
  • Extracts the date portion by splitting on 'T' and validates the format
  • Updates each filter value individually with proper error handling
  • Supports dry-run mode for safe testing
  • Includes comprehensive logging for tracking progress and issues

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - it's a straightforward data migration with proper safeguards
  • The migration logic is sound with proper error handling, validation, and dry-run support. The null check for filter.fieldMetadata addresses the concern from the previous thread. The only minor consideration is ensuring this migration runs after the corresponding code fix is deployed.
  • No files require special attention - the implementation follows established migration patterns

Important Files Changed

Filename Overview
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-migrate-date-time-is-filter-values.command.ts New migration command to convert DATE_TIME IS filter values from ISO datetime format to plain date format, includes proper error handling and dry-run support
packages/twenty-server/src/database/commands/upgrade-version-command/1-17/1-17-upgrade-version-command.module.ts Registers the new migration command and its dependencies in the module

Sequence Diagram

sequenceDiagram
    participant CLI as CLI Command
    participant Cmd as MigrateDateTimeIsFilterValuesCommand
    participant VFR as ViewFilterRepository
    participant DB as Database

    CLI->>Cmd: runOnWorkspace(workspaceId, options)
    Cmd->>VFR: find(where: {workspaceId}, relations: ['fieldMetadata'])
    VFR->>DB: Query view filters with field metadata
    DB-->>VFR: Return view filters
    VFR-->>Cmd: viewFilters[]
    
    Cmd->>Cmd: Filter by DATE_TIME type + IS operand + value contains 'T'
    Cmd->>Cmd: filtersToUpdate[]
    
    alt No filters to update
        Cmd-->>CLI: Early return
    end
    
    alt isDryRun
        Cmd->>Cmd: Log dry run message
        Cmd-->>CLI: Return without updates
    else Update mode
        loop For each filter
            Cmd->>Cmd: Split value by 'T' to extract date
            Cmd->>Cmd: Validate date format (YYYY-MM-DD)
            alt Valid date
                Cmd->>VFR: update(filterId, {value: newDate})
                VFR->>DB: Update view filter value
                DB-->>VFR: Success
                VFR-->>Cmd: Updated
                Cmd->>Cmd: Increment updatedCount
            else Invalid date
                Cmd->>Cmd: Log warning and skip
            end
        end
        Cmd->>Cmd: Log migration summary
        Cmd-->>CLI: Complete
    end
Loading
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@github-actions
Copy link
Contributor

github-actions bot commented Jan 29, 2026

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:14644

This environment will automatically shut down when the PR is closed or after 5 hours.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 811 files

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/twenty-front/src/modules/command-menu/components/hooks/usePageLayoutHeaderInfo.ts">

<violation number="1" location="packages/twenty-front/src/modules/command-menu/components/hooks/usePageLayoutHeaderInfo.ts:132">
P2: Graph type labels already include "Chart", so appending another " Chart" results in duplicated titles (e.g., "Pie Chart Chart") for the graph filter header.</violation>
</file>

<file name="packages/twenty-docker/helm/twenty/templates/secret-db-url.yaml">

<violation number="1" location="packages/twenty-docker/helm/twenty/templates/secret-db-url.yaml:2">
P2: Secret DB URL is always generated for the internal DB service; when db.enabled=false/external DB is used, PG_DATABASE_URL still points to the internal service and breaks external DB setups.</violation>
</file>

<file name="packages/twenty-docker/helm/twenty/templates/deployment-worker.yaml">

<violation number="1" location="packages/twenty-docker/helm/twenty/templates/deployment-worker.yaml:58">
P2: Worker now always expects the fixed "<fullname>-db-url" secret, while the only db-url secret template builds an internal DB URL. External DB/external-secret configurations lose their conditional handling and will fail to provide the expected secret/URL, breaking external DB setups.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

const headerType =
commandMenuPage === CommandMenuPages.PageLayoutGraphFilter
? graphTypeLabel
? t`${graphTypeLabel} Chart`
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Graph type labels already include "Chart", so appending another " Chart" results in duplicated titles (e.g., "Pie Chart Chart") for the graph filter header.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-front/src/modules/command-menu/components/hooks/usePageLayoutHeaderInfo.ts, line 132:

<comment>Graph type labels already include "Chart", so appending another " Chart" results in duplicated titles (e.g., "Pie Chart Chart") for the graph filter header.</comment>

<file context>
@@ -129,7 +129,7 @@ export const usePageLayoutHeaderInfo = ({
       const headerType =
         commandMenuPage === CommandMenuPages.PageLayoutGraphFilter
-          ? graphTypeLabel
+          ? t`${graphTypeLabel} Chart`
           : t`Chart`;
 
</file context>
Suggested change
? t`${graphTypeLabel} Chart`
? graphTypeLabel
Fix with Cubic
@@ -1,5 +1,4 @@
{{- $secretName := printf "%s-db-url" (include "twenty.fullname" .) -}}
{{- if .Values.db.enabled -}}
{{- $existingSecret := lookup "v1" "Secret" (include "twenty.namespace" .) $secretName -}}
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Secret DB URL is always generated for the internal DB service; when db.enabled=false/external DB is used, PG_DATABASE_URL still points to the internal service and breaks external DB setups.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-docker/helm/twenty/templates/secret-db-url.yaml, line 2:

<comment>Secret DB URL is always generated for the internal DB service; when db.enabled=false/external DB is used, PG_DATABASE_URL still points to the internal service and breaks external DB setups.</comment>

<file context>
@@ -1,5 +1,4 @@
 {{- $secretName := printf "%s-db-url" (include "twenty.fullname" .) -}}
-{{- if .Values.db.enabled -}}
 {{- $existingSecret := lookup "v1" "Secret" (include "twenty.namespace" .) $secretName -}}
 {{- $appPassword := "" -}}
 {{- if $existingSecret -}}
</file context>
Fix with Cubic
valueFrom:
secretKeyRef:
name: {{ include "twenty.dbUrl.secretName" . }}
name: {{ include "twenty.fullname" . }}-db-url
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Worker now always expects the fixed "-db-url" secret, while the only db-url secret template builds an internal DB URL. External DB/external-secret configurations lose their conditional handling and will fail to provide the expected secret/URL, breaking external DB setups.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/twenty-docker/helm/twenty/templates/deployment-worker.yaml, line 58:

<comment>Worker now always expects the fixed "<fullname>-db-url" secret, while the only db-url secret template builds an internal DB URL. External DB/external-secret configurations lose their conditional handling and will fail to provide the expected secret/URL, breaking external DB setups.</comment>

<file context>
@@ -52,21 +52,11 @@ spec:
               valueFrom:
                 secretKeyRef:
-                  name: {{ include "twenty.dbUrl.secretName" . }}
+                  name: {{ include "twenty.fullname" . }}-db-url
                   key: url
-            {{- end }}
</file context>
Fix with Cubic
@carbonFibreCode carbonFibreCode force-pushed the fix/date-time-migration branch from 043d5c6 to 004b453 Compare January 31, 2026 21:44
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants