Skip to content

fix: More deployment version refactor#371

Merged
adityachoudhari26 merged 1 commit intomainfrom
more-deployment-version-refactor
Mar 12, 2025
Merged

fix: More deployment version refactor#371
adityachoudhari26 merged 1 commit intomainfrom
more-deployment-version-refactor

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Mar 12, 2025

Summary by CodeRabbit

  • Refactor

    • Consolidated and standardized data references across the application to improve maintainability and consistency in database operations and UI rendering.
    • Updated internal query logic and component types to ensure a uniform handling of release-related information without impacting visible functionality.
  • Chores

    • Streamlined module imports to use a unified namespace for better code organization.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 12, 2025

Walkthrough

This pull request refactors the way database schema entities are imported and referenced across the codebase. The changes consolidate multiple individual imports into a single namespace import (SCHEMA), and update all function calls, join conditions, type definitions, and query fragments to use this namespace. In many cases, references to the Release entity are replaced with DeploymentVersion to reflect a revised data model. These modifications span multiple areas including event worker jobs, API routes, webservice components, various policies, and tests.

Changes

File(s) Change Summary
apps/event-worker/src/job-dispatch/github.ts Refactored database schema imports: updated function calls (getGithubEntity, getReleaseJobAgentConfig) to use SCHEMA namespace.
apps/jobs/src/timeout-checker/index.ts Modified inner join conditions: replaced joins on SCHEMA.release with SCHEMA.deploymentVersion.
apps/webservice/src/app/[workspaceSlug]/(app)/_components/ReleaseBadgeList.tsx, .../deployment-resource-drawer/TableRow.tsx, .../release-drawer/OverviewContent.tsx, .../dependencies/DependencyDiagram.tsx Updated type definitions for props and component interfaces; changed references from SCHEMA.Release to SCHEMA.DeploymentVersion and adjusted SQL join conditions accordingly.
apps/webservice/src/app/api/v1/* (multiple route files) Updated database queries in GET, PATCH, and INSERT operations: switched from SCHEMA.release to SCHEMA.deploymentVersion in from, where, and join clauses.
packages/api/src/router/*, packages/auth/src/utils/rbac.ts Refactored router queries and RBAC logic: consolidated schema imports to SCHEMA and updated join conditions and query filters to target SCHEMA.deploymentVersion.
packages/db/src/schema/* Renamed and updated schema declarations: replaced release with deploymentVersion in table definitions, foreign key references, and helper functions.
packages/job-dispatch/src/** (tests, query functions, policies, job handling modules) Systematic update across job dispatch logic and policies: changed join conditions, query filters, and parameter types from SCHEMA.Release to SCHEMA.DeploymentVersion while standardizing schema access via the SCHEMA import.

Possibly related PRs

Poem

I hopped through lines of code so fine,
Refactoring imports into one clear design.
From Release to DeploymentVersion I did leap,
With SCHEMA as my guide, my changes run deep.
In fields of SQL and TypeScript I play,
A happy rabbit celebrates this refactor-day!
🥕🐇

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
packages/db/src/schema/release.ts (1)

135-151: 🛠️ Refactor suggestion

Rename function to match new entity name.

Currently named createRelease but now references deploymentVersion. Renaming is advisable to avoid confusion:

-export const createRelease = createInsertSchema(deploymentVersion, {
+export const createDeploymentVersion = createInsertSchema(deploymentVersion, {
🧹 Nitpick comments (12)
packages/api/src/router/resource-stats.ts (1)

104-110: Consider renaming the response property for API consistency.

While the schema has been updated to use DeploymentVersion, the API still returns a release property that is assigned the value from row.deployment_version. For consistency, consider renaming this to deploymentVersion in the returned object to match the schema changes.

  .then((rows) =>
    rows.map((row) => ({
      ...row.job,
      deployment: row.deployment,
-     release: row.deployment_version,
+     deploymentVersion: row.deployment_version,
    })),
  );
apps/webservice/src/app/api/v1/releases/[releaseId]/route.ts (1)

45-47: Rename local variable for clarity
You have updated the table reference from SCHEMA.release to SCHEMA.deploymentVersion, yet the local variable is still called release. Consider renaming it (e.g., deploymentVersion) to avoid confusion and maintain consistency.

packages/job-dispatch/src/policies/release-dependency.ts (2)

20-25: Align property names with updated schema
The parameter trigger.releaseId now points to schema.deploymentVersion.id. Consider renaming it to something like deploymentVersionId to maintain clarity and consistency, especially since the table is now deploymentVersion instead of release.


110-118: Revisit remaining “release” references
You replaced references to the old release schema with deploymentVersion, but there are still references like releaseMatchesCondition and latestJobSubquery.releaseId. If it now pertains to deployment versions, consider renaming these for consistency.

packages/job-dispatch/src/policies/release-sequencing.ts (1)

88-88: Parameter naming inconsistency.

The parameter is still named release, but the type is now schema.DeploymentVersion. Consider renaming the parameter for clarity.

-const isReleaseLatestActiveForEnvironment = async (db: Tx, release: schema.DeploymentVersion, environmentId: string) => {
+const isReleaseLatestActiveForEnvironment = async (db: Tx, deploymentVersion: schema.DeploymentVersion, environmentId: string) => {
packages/api/src/router/job.ts (1)

66-66: Parameter name mismatch.

This field is named release while referencing schema.DeploymentVersion. For clarity, rename it if possible.

-release: schema.DeploymentVersion;
+deploymentVersion: schema.DeploymentVersion;
packages/api/src/router/deployment.ts (6)

45-46: Schema Update for Release Channel Update Input
Using SCHEMA.updateReleaseChannel inside the input declaration standardizes the update validation. Double-check that this schema reflects all required fields and constraints as per the new data model.


87-98: Refactored List Procedure for Release Channels
The list query now selects from SCHEMA.releaseChannel and, for calculating counts, from SCHEMA.deploymentVersion using the helper SCHEMA.releaseMatchesCondition. Please verify that the condition logic within SCHEMA.releaseMatchesCondition correctly filters the records as intended.


388-395: Joining Deployment Versions in Distribution Query
The subsequent join with SCHEMA.deploymentVersion and SCHEMA.resource integrates the new naming by replacing previous release references. Consider if the returned key "release" (line 400) should be renamed for consistency with the deployment version terminology.


487-507: BySlug Query with Consolidated Schema Imports
The join operations among SCHEMA.deployment, SCHEMA.system, SCHEMA.workspace, and SCHEMA.jobAgent have been updated to use the schema namespace. Ensure that the aliasing (e.g., for job agent and any channel data) reflects the new data model semantics correctly.


514-523: Result Mapping in BySlug Query
The mapping of the query result (e.g., spreading r[0].deployment, wrapping system data, and collecting releaseChannels) should be reviewed for consistency in naming. Consider whether the key "releaseChannels" accurately reflects the new deployment version context or if a rename (e.g., "deploymentChannels") might improve clarity.


604-697: Complex Query in ByResourceId Procedure Using Schema References
This extensive query involves multiple joins across SCHEMA.resource, SCHEMA.environment, SCHEMA.deployment, and related tables. Please verify that:

  • The use of the helper function SCHEMA.resourceMatchesMetadata integrates seamlessly with the rest of the query.
  • The ordering and limit constraints (e.g., .orderBy and .limit(500)) deliver acceptable performance given the multiple joins and filtering conditions.
    Consider adding inline comments or refactoring parts of the query into helper functions to improve readability and maintainability.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da8d799 and 6b71807.

📒 Files selected for processing (51)
  • apps/event-worker/src/job-dispatch/github.ts (3 hunks)
  • apps/jobs/src/timeout-checker/index.ts (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/ReleaseBadgeList.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/TableRow.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-drawer/OverviewContent.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/dependencies/DependencyDiagram.tsx (5 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowDiagram.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowNode.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowPolicyNode.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/TriggerNode.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/_components/deployments/DeploymentDirectoryCell.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/deployments/resource-drawer/TableRow.tsx (2 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/ReleaseBadgeList.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/resources/ReleaseCell.tsx (3 hunks)
  • apps/webservice/src/app/api/v1/config/route.ts (2 hunks)
  • apps/webservice/src/app/api/v1/job-agents/[agentId]/jobs/running/route.ts (2 hunks)
  • apps/webservice/src/app/api/v1/jobs/[jobId]/route.ts (1 hunks)
  • apps/webservice/src/app/api/v1/releases/[releaseId]/route.ts (1 hunks)
  • apps/webservice/src/app/api/v1/releases/route.ts (1 hunks)
  • packages/api/src/router/deployment-stats.ts (4 hunks)
  • packages/api/src/router/deployment.ts (29 hunks)
  • packages/api/src/router/environment-approval.ts (1 hunks)
  • packages/api/src/router/environment-stats.ts (2 hunks)
  • packages/api/src/router/job.ts (8 hunks)
  • packages/api/src/router/release-deploy.ts (3 hunks)
  • packages/api/src/router/release-metadata-keys.ts (3 hunks)
  • packages/api/src/router/release.ts (16 hunks)
  • packages/api/src/router/resource-stats.ts (2 hunks)
  • packages/api/src/router/resources.ts (3 hunks)
  • packages/auth/src/utils/rbac.ts (3 hunks)
  • packages/db/src/schema/environment.ts (2 hunks)
  • packages/db/src/schema/job.ts (3 hunks)
  • packages/db/src/schema/release.ts (12 hunks)
  • packages/job-dispatch/src/__test__/job-variables-deployment.test.ts (2 hunks)
  • packages/job-dispatch/src/environment-creation.ts (1 hunks)
  • packages/job-dispatch/src/environment-release-channel-update.ts (2 hunks)
  • packages/job-dispatch/src/job-creation.ts (3 hunks)
  • packages/job-dispatch/src/job-failure.ts (1 hunks)
  • packages/job-dispatch/src/job-variables-deployment/utils.ts (1 hunks)
  • packages/job-dispatch/src/policies/concurrency-policy.ts (5 hunks)
  • packages/job-dispatch/src/policies/gradual-rollout.ts (2 hunks)
  • packages/job-dispatch/src/policies/manual-approval.ts (2 hunks)
  • packages/job-dispatch/src/policies/min-release-interval-policy.ts (4 hunks)
  • packages/job-dispatch/src/policies/release-dependency.ts (2 hunks)
  • packages/job-dispatch/src/policies/release-sequencing.ts (6 hunks)
  • packages/job-dispatch/src/policies/release-string-check.ts (2 hunks)
  • packages/job-dispatch/src/policies/success-rate-criteria-passing.ts (2 hunks)
  • packages/job-dispatch/src/policy-create.ts (1 hunks)
  • packages/job-dispatch/src/release-job-trigger.ts (5 hunks)
  • packages/job-dispatch/src/release-sequencing.ts (1 hunks)
  • packages/job-dispatch/src/resource/dispatch-resource.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict en...

**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

  • apps/webservice/src/app/api/v1/jobs/[jobId]/route.ts
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowNode.tsx
  • packages/job-dispatch/src/resource/dispatch-resource.ts
  • packages/job-dispatch/src/release-sequencing.ts
  • apps/webservice/src/app/api/v1/config/route.ts
  • apps/webservice/src/app/api/v1/job-agents/[agentId]/jobs/running/route.ts
  • apps/jobs/src/timeout-checker/index.ts
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowPolicyNode.tsx
  • packages/job-dispatch/src/policies/concurrency-policy.ts
  • packages/api/src/router/deployment-stats.ts
  • packages/job-dispatch/src/policies/release-string-check.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/TableRow.tsx
  • packages/db/src/schema/environment.ts
  • packages/job-dispatch/src/policies/min-release-interval-policy.ts
  • packages/job-dispatch/src/job-failure.ts
  • packages/job-dispatch/src/policies/manual-approval.ts
  • packages/api/src/router/resources.ts
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/deployments/resource-drawer/TableRow.tsx
  • packages/job-dispatch/src/policies/gradual-rollout.ts
  • apps/webservice/src/app/api/v1/releases/route.ts
  • apps/event-worker/src/job-dispatch/github.ts
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/_components/deployments/DeploymentDirectoryCell.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/ReleaseBadgeList.tsx
  • packages/job-dispatch/src/__test__/job-variables-deployment.test.ts
  • packages/job-dispatch/src/policy-create.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-drawer/OverviewContent.tsx
  • apps/webservice/src/app/api/v1/releases/[releaseId]/route.ts
  • packages/api/src/router/environment-approval.ts
  • packages/api/src/router/release-metadata-keys.ts
  • packages/job-dispatch/src/environment-release-channel-update.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/dependencies/DependencyDiagram.tsx
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/ReleaseBadgeList.tsx
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/TriggerNode.tsx
  • packages/job-dispatch/src/policies/success-rate-criteria-passing.ts
  • packages/job-dispatch/src/environment-creation.ts
  • packages/api/src/router/resource-stats.ts
  • packages/job-dispatch/src/policies/release-dependency.ts
  • packages/api/src/router/release-deploy.ts
  • packages/auth/src/utils/rbac.ts
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/resources/ReleaseCell.tsx
  • packages/api/src/router/release.ts
  • packages/db/src/schema/job.ts
  • apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowDiagram.tsx
  • packages/api/src/router/environment-stats.ts
  • packages/db/src/schema/release.ts
  • packages/job-dispatch/src/job-creation.ts
  • packages/job-dispatch/src/job-variables-deployment/utils.ts
  • packages/job-dispatch/src/policies/release-sequencing.ts
  • packages/api/src/router/job.ts
  • packages/api/src/router/deployment.ts
  • packages/job-dispatch/src/release-job-trigger.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Typecheck
  • GitHub Check: build (linux/amd64)
  • GitHub Check: build (linux/amd64)
  • GitHub Check: Lint
🔇 Additional comments (166)
apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/_components/deployments/DeploymentDirectoryCell.tsx (1)

27-27: Type update looks good!

The change from SCHEMA.Release to SCHEMA.DeploymentVersion aligns with the broader schema refactoring across the codebase. The component continues to work correctly as it accesses the same properties (id, version, createdAt) which exist in both types.

packages/job-dispatch/src/environment-creation.ts (1)

56-64: Schema references updated correctly

The changes properly update all references from SCHEMA.release to SCHEMA.deploymentVersion while maintaining the same query structure. The function continues to work with the same underlying data model, just with the renamed schema entity.

packages/job-dispatch/src/resource/dispatch-resource.ts (1)

85-93: Schema references consistently updated

The changes properly update all references from SCHEMA.release to SCHEMA.deploymentVersion in the database query. This maintains consistency with the schema refactoring across the codebase while preserving the existing query logic.

apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/ReleaseBadgeList.tsx (1)

7-7: Type definition correctly updated

The property type update from SCHEMA.Release[] to SCHEMA.DeploymentVersion[] aligns with the schema refactoring. The component still accesses the same properties (id and name), which exist in both types, ensuring the component functions correctly with the new type.

packages/job-dispatch/src/environment-release-channel-update.ts (4)

74-77: Schema entity replacements look good

The inner join has been correctly updated from using SCHEMA.release to SCHEMA.deploymentVersion, maintaining the same relationship with SCHEMA.releaseJobTrigger.releaseId.


79-81: Deployment reference properly updated

The condition has been correctly updated to reference SCHEMA.deploymentVersion.deploymentId instead of the previous SCHEMA.release.deploymentId.


101-107: Data source correctly refactored

The select query has been properly updated to use SCHEMA.deploymentVersion as the data source instead of SCHEMA.release.


110-111: Sort order maintained in new entity

The ordering has been properly updated to use SCHEMA.deploymentVersion.createdAt maintaining the same sort behavior after the schema entity change.

packages/job-dispatch/src/release-job-trigger.ts (8)

11-11: Import refactoring looks good

The migration from individual schema imports to a consolidated namespace import improves code organization.


78-88: References properly updated with namespace

All entity references have been correctly updated to use the SCHEMA namespace, and release references have been replaced with deploymentVersion.


91-103: Base query joins consistently updated

All join conditions have been properly updated to use the SCHEMA namespace, maintaining the same relationship logic.


105-118: Release subquery properly refactored

The method has been updated to reference SCHEMA.deploymentVersion entities instead of release, maintaining the same functionality with the new schema structure.


122-136: Branch conditions properly updated

Both conditional branches in the _values method have been updated to use the new schema references, ensuring consistent behavior across code paths.


144-156: Resource query conditions updated correctly

All conditions in the resource query have been updated to use the SCHEMA namespace, preserving the original query logic.


184-200: Release query properly refactored

The joins and conditions have been correctly updated to use SCHEMA.deploymentVersion instead of release, maintaining the same relationships.


220-223: Insert operation updated consistently

The insert operation now correctly uses the SCHEMA namespace, maintaining the same functionality.

packages/job-dispatch/src/policy-create.ts (3)

6-6: Import refactoring looks good

The migration from individual schema imports to a consolidated namespace import improves code organization.


12-38: Query structure properly refactored

The selectDistinctOn, from clause, and all join conditions have been updated to use the SCHEMA namespace and replace release references with deploymentVersion, maintaining the same query logic.


42-50: Insert operation updated correctly

The insert operation has been updated to use the SCHEMA namespace, and the mapping now correctly references p.deployment_version.id instead of release.

apps/webservice/src/app/api/v1/jobs/[jobId]/route.ts (3)

84-87: Schema entity replacement looks good

The left join has been correctly updated to use schema.deploymentVersion instead of schema.release, maintaining the same relationship with schema.releaseJobTrigger.releaseId.


88-91: Deployment join condition properly updated

The join condition has been correctly updated to reference schema.deploymentVersion.deploymentId instead of schema.release.deploymentId.


104-107: Release reference properly updated

The conditional check and object creation now correctly use row.deployment_version instead of row.release.

packages/job-dispatch/src/job-variables-deployment/utils.ts (2)

24-28: LGTM: Consistent schema refactoring

The join has been correctly updated from SCHEMA.release to SCHEMA.deploymentVersion, maintaining the same relationship between tables while aligning with the broader schema refactoring effort.


30-30: LGTM: Consistent where clause update

The where clause has been properly updated to filter by SCHEMA.deploymentVersion.id instead of SCHEMA.release.id, maintaining query functionality while following the schema refactoring pattern.

apps/jobs/src/timeout-checker/index.ts (2)

12-13: LGTM: Consistent schema refactoring in join clause

The join has been correctly updated from SCHEMA.release to SCHEMA.deploymentVersion, maintaining the same query structure while aligning with the refactoring effort.


17-17: LGTM: Properly updated join condition

The join condition has been correctly updated to use SCHEMA.deploymentVersion.id instead of SCHEMA.release.id, maintaining the same relationship between tables in the query.

apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/TriggerNode.tsx (1)

7-7: LGTM: Type definition updated consistently

The type definition has been properly updated from SCHEMA.Release to SCHEMA.DeploymentVersion, aligning with the broader schema refactoring across the codebase.

apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowNode.tsx (2)

1-1: LGTM: Import style updated to use namespace

Import updated to use the SCHEMA namespace, which is consistent with the refactoring pattern seen throughout the PR.


14-14: LGTM: Type definition updated consistently

The type definition has been properly updated to use SCHEMA.Environment and SCHEMA.DeploymentVersion instead of direct imports, maintaining component functionality while aligning with the schema refactoring.

packages/api/src/router/environment-approval.ts (2)

109-111: Entity reference updated correctly

The inner join now correctly references SCHEMA.deploymentVersion instead of SCHEMA.release, maintaining proper relationship between release job triggers and deployment versions.


115-115: Where clause condition updated properly

The condition is correctly updated to check against SCHEMA.deploymentVersion.id instead of SCHEMA.release.id, maintaining consistency with the schema refactoring.

apps/webservice/src/app/api/v1/releases/route.ts (2)

56-63: Entity reference updated correctly

The select query has been properly updated to use schema.deploymentVersion instead of schema.release, with appropriate where clause conditions using the new schema entity.


65-82: Insert and conflict resolution properly refactored

The insert operation and conflict resolution logic have been correctly updated to use schema.deploymentVersion instead of schema.release, including proper target fields and conflict column sets.

apps/webservice/src/app/api/v1/config/route.ts (2)

161-164: Left join updated correctly

The left join has been appropriately updated to join with schema.deploymentVersion instead of schema.release, maintaining the correct relationship with the deployment entity.


212-214: Insert target updated properly

The insert operation now correctly targets schema.deploymentVersion instead of schema.release, aligning with the schema refactoring across the codebase.

packages/job-dispatch/src/policies/release-string-check.ts (2)

68-70: Query updated correctly

The select query has been properly updated to use schema.deploymentVersion instead of schema.release, with the appropriate where clause condition.


86-95: Matching release query updated properly

The query to find matching releases now correctly references schema.deploymentVersion instead of schema.release, ensuring consistency with the schema refactoring.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/ReleaseBadgeList.tsx (1)

7-7: Type change looks good.

The change from SCHEMA.Release[] to SCHEMA.DeploymentVersion[] aligns with the broader refactoring to standardize on DeploymentVersion across the codebase. The component functionality remains unchanged since both types appear to have the required id and name properties used in the template.

packages/api/src/router/resource-stats.ts (3)

79-83: Query schema references updated correctly.

The changes from SCHEMA.release to SCHEMA.deploymentVersion in the selectDistinctOn method and from clause accurately reflect the schema migration. The join condition has also been properly updated to match the new entity names.


91-92: Join condition updated correctly.

The inner join between deployment and deployment version tables has been properly updated to reflect the new schema structure.


100-103: Order by clause updated correctly.

The orderBy clause now correctly references the deploymentVersion table instead of the release table, maintaining the same sorting logic.

packages/job-dispatch/src/release-sequencing.ts (4)

29-33: SQL subquery updated correctly.

The schema references in the trigger subquery have been properly updated from release to deploymentVersion, maintaining the same logical structure while reflecting the new schema design.


35-36: Join conditions properly refactored.

The inner join expressions have been updated to use the new deploymentVersion schema instead of release, with appropriate relationship paths maintained.


43-45: Join conditions for job cancellation updated correctly.

The join conditions in the jobs cancellation query have been properly updated to use the new schema entities.


50-52: Cancel conditions updated correctly.

The conditions used to determine which jobs to cancel have been updated to reference the deployment version ID and creation time instead of release fields.

apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowPolicyNode.tsx (3)

1-1: Import style standardized.

The change to a namespace import for the schema types is consistent with the refactoring approach used throughout the codebase.


17-19: Type references updated correctly.

The PolicyNodeProps type definition has been properly updated to use the SCHEMA namespace and to reference DeploymentVersion instead of Release. This ensures type safety while maintaining the same property name for backward compatibility.


1-186: Path naming inconsistency relative to component name.

The component path contains "releases/[releaseId]" while the component now works with DeploymentVersion. The URL structure might need to be updated in a future PR to reflect this schema change, or a justification added for keeping the old naming in the URL.

This is just an observation - no immediate changes needed, but it might be worth documenting the reason for keeping "releases" in the URL path while using DeploymentVersion in the code or planning for URL structure updates in a follow-up PR.

packages/job-dispatch/src/job-failure.ts (2)

15-16: LGTM: Successfully updated join reference to deploymentVersion

The change correctly updates the inner join to reference the new schema.deploymentVersion entity instead of the previous schema.release entity, aligning with the broader refactoring effort.


20-20: LGTM: Properly updated join condition

The join condition is correctly updated to use schema.deploymentVersion.deploymentId instead of the previous schema.release.deploymentId, maintaining the relationship integrity in the query.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-drawer/OverviewContent.tsx (3)

3-3: LGTM: Added namespace import for schema types

Good change to use a namespace import for schema types, which is consistent with the refactoring approach seen across the codebase.


19-19: LGTM: Updated component prop type

Correctly updated the release prop type from direct Release import to use the namespaced SCHEMA.DeploymentVersion, maintaining type safety while adopting the new naming convention.


21-21: LGTM: Updated dependencies type

The type for dependencies is properly updated to use the namespaced SCHEMA.ReleaseDependency[] type definition.

packages/api/src/router/environment-stats.ts (3)

42-42: LGTM: Updated SQL rank calculation

The SQL query for rank calculation is correctly updated to use SCHEMA.deploymentVersion.deploymentId instead of the previous release reference, maintaining the partitioning logic.


53-54: LGTM: Updated inner join to deploymentVersion

Successfully replaced the inner join to SCHEMA.release with SCHEMA.deploymentVersion, ensuring consistency with the updated data model.


58-58: LGTM: Updated join condition

The join condition for the deployment table is properly updated to reference SCHEMA.deploymentVersion.deploymentId.

packages/job-dispatch/src/policies/min-release-interval-policy.ts (7)

24-25: LGTM: Updated field references

Correctly updated field references from SCHEMA.release to SCHEMA.deploymentVersion in the select statement.


27-27: LGTM: Updated SQL rank calculation

The SQL partitioning expression is properly updated to reference SCHEMA.deploymentVersion.deploymentId and SCHEMA.deploymentVersion.createdAt.


31-31: LGTM: Updated from clause

The from clause is correctly updated to select from SCHEMA.deploymentVersion instead of SCHEMA.release.


44-47: LGTM: Updated equality condition

Successfully updated the equality condition to compare SCHEMA.releaseJobTrigger.releaseId with SCHEMA.deploymentVersion.id.


66-69: LGTM: Updated second equality condition

Properly updated the second equality condition in the notExists clause to reference SCHEMA.deploymentVersion.id.


100-100: LGTM: Updated from clause in second query

The from clause in the second query is correctly updated to select from SCHEMA.deploymentVersion.


103-103: LGTM: Updated id reference in where clause

Successfully updated the id reference in the where clause to use SCHEMA.deploymentVersion.id.

packages/job-dispatch/src/policies/manual-approval.ts (2)

24-25: Reference updated correctly to use deploymentVersion.

The schema reference has been properly updated from release to deploymentVersion, maintaining the correct relationship with releaseJobTrigger.releaseId.


38-41: Join condition correctly updated to use deploymentVersion.id.

The join condition has been properly updated to reference schema.deploymentVersion.id instead of schema.release.id, maintaining the correct relationship with environmentPolicyApproval.releaseId.

packages/db/src/schema/environment.ts (2)

26-26: Import statement correctly updated.

The import has been properly updated from release to deploymentVersion to align with the data model changes.


264-264: Foreign key reference properly updated.

The foreign key reference has been correctly updated to reference deploymentVersion.id instead of release.id, ensuring database integrity with the new data model.

packages/api/src/router/resources.ts (5)

97-100: ROW_NUMBER() partitioning correctly updated.

The PARTITION BY clause in the ROW_NUMBER() function has been properly updated to use schema.deploymentVersion.deploymentId, and the corresponding rankDeploymentId variable has been updated to match.


104-108: Source table and join condition correctly updated.

The source table for the rank subquery has been properly updated from schema.release to schema.deploymentVersion, and the join condition has been updated to maintain the correct relationship with releaseJobTrigger.


120-122: Inner join correctly updated to use deploymentVersion.

The inner join has been properly updated to use schema.deploymentVersion and the correct join condition with deployment.id.


126-126: Join condition correctly updated.

The join condition has been properly updated to reference schema.deploymentVersion.id instead of schema.release.id.


137-140: Rank subquery join condition correctly updated.

The condition for joining the rankSubquery has been properly updated to compare with schema.deploymentVersion.deploymentId instead of schema.release.deploymentId.

packages/job-dispatch/src/job-creation.ts (6)

81-83: Inner join correctly updated to use deploymentVersion.

The inner join has been properly updated to connect schema.releaseJobTrigger.releaseId to schema.deploymentVersion.id instead of schema.release.id.


86-87: Join condition correctly updated.

The inner join condition has been properly updated to connect schema.deploymentVersion.deploymentId to schema.deployment.id instead of schema.release.deploymentId.


106-110: Concurrency requirement condition correctly updated.

The condition checking for concurrency requirements has been properly updated to compare schema.deploymentVersion.deploymentId with triggers.deployment_version.deploymentId instead of schema.release.deploymentId.


120-121: Waiting condition correctly updated.

The condition for checking if a job is waiting on another job to finish has been properly updated to compare schema.deploymentVersion.id with triggers.deployment_version.id instead of schema.release.id.


127-129: Inner join correctly updated in affected queries.

The inner join for affected release job triggers has been properly updated to connect schema.releaseJobTrigger.releaseId to schema.deploymentVersion.id instead of schema.release.id.


132-133: Deployment join condition correctly updated.

The inner join condition has been properly updated to connect schema.deploymentVersion.deploymentId to schema.deployment.id instead of schema.release.deploymentId.

apps/event-worker/src/job-dispatch/github.ts (3)

6-6: LGTM! Consolidated schema imports.

This change is part of the broader refactoring to consolidate database schema imports into a single namespace import, which improves code organization.


21-25: Properly updated schema references in the query.

The query now correctly uses the SCHEMA namespace for githubEntity and workspace entities.


84-91: Renamed entity from 'release' to 'deploymentVersion'.

This change correctly updates the query to use deploymentVersion instead of release, aligning with the data model changes across the codebase.

packages/api/src/router/release-metadata-keys.ts (3)

5-5: LGTM! Consolidated schema imports.

Importing all schema entities under a single namespace improves code organization and maintainability.


22-33: Correctly updated schema references in the 'bySystem' query.

The query properly uses the SCHEMA namespace and references deploymentVersion instead of release, maintaining functionality while improving code clarity.


47-62: Correctly updated schema references in the 'byWorkspace' query.

All entity references have been properly updated to use the SCHEMA namespace and deploymentVersion, consistent with the data model changes.

packages/auth/src/utils/rbac.ts (3)

15-15: Added deploymentVersion to imports.

Correctly added deploymentVersion to the list of imported schema entities to support the refactoring.


97-102: Updated getReleaseScopes to use deploymentVersion.

The function now correctly joins on deploymentVersion instead of release, aligning with the new data model.


359-364: Updated getJobScopes to use deploymentVersion.

The join logic has been properly updated to reference deploymentVersion instead of release, maintaining the relationship between entities while reflecting the data model changes.

apps/webservice/src/app/[workspaceSlug]/(app)/_components/deployment-resource-drawer/TableRow.tsx (2)

73-73: Updated type from Release to DeploymentVersion.

The type of the release property in DropdownCellProps has been correctly updated to SCHEMA.DeploymentVersion, consistent with the entity name change.


87-87: Updated type from Release to DeploymentVersion.

The type of the release property in ReleaseJobTriggerRowProps has been correctly updated to SCHEMA.DeploymentVersion, ensuring type consistency across the codebase.

apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/deployments/resource-drawer/TableRow.tsx (2)

73-73: Type reference updated to reflect schema change.

The type for the release property has been correctly updated from SCHEMA.Release to SCHEMA.DeploymentVersion to align with the broader schema refactoring.


87-87: Type reference updated to reflect schema change.

The type for the release property has been correctly updated from SCHEMA.Release to SCHEMA.DeploymentVersion, maintaining consistency with the schema refactoring across the codebase.

apps/webservice/src/app/api/v1/job-agents/[agentId]/jobs/running/route.ts (3)

8-8: Import refactored to use namespace pattern.

The import has been updated to use a single namespace import for all schema entities, which simplifies imports and aligns with the broader refactoring approach.


24-48: Database query updated to use SCHEMA namespace and DeploymentVersion entity.

The database query has been correctly updated to:

  1. Use the SCHEMA. prefix for all entity references
  2. Replace release with deploymentVersion in the join conditions

This maintains consistency with the schema refactoring while preserving the original query logic.


51-59: Where clause updated to use SCHEMA namespace.

The where clause conditions have been properly updated to use the SCHEMA. prefix for all entity references, completing the refactoring of this database query.

packages/job-dispatch/src/__test__/job-variables-deployment.test.ts (2)

72-72: Constant type updated to reflect schema change.

The type for the deployment_version constant has been correctly updated from SCHEMA.Release to SCHEMA.DeploymentVersion, aligning with the schema refactoring initiative.


107-107: Variable type updated for consistency.

The type definition for the deployment_version property in the variable type has been updated to SCHEMA.DeploymentVersion, maintaining consistency with the schema changes throughout the codebase.

packages/job-dispatch/src/policies/concurrency-policy.ts (5)

27-29: Join updated to use DeploymentVersion entity.

The join has been updated to use schema.deploymentVersion instead of schema.release, correctly implementing the schema change while preserving the join logic.


65-66: Updated field reference to use DeploymentVersion.

The field reference for deploymentId now correctly uses schema.deploymentVersion.deploymentId, consistent with the schema changes.


78-80: Join updated to use DeploymentVersion entity.

Another join to schema.release has been properly updated to use schema.deploymentVersion, maintaining consistency throughout the query.


91-95: Entity reference updated in filter condition.

The reference to schema.release.deploymentId has been changed to schema.deploymentVersion.deploymentId in the filter conditions, correctly implementing the schema change.


104-107: Group by clause updated to use DeploymentVersion entity.

The group by clause has been updated to use schema.deploymentVersion.deploymentId instead of schema.release.deploymentId, completing the consistent application of the schema change throughout this query.

packages/api/src/router/deployment-stats.ts (4)

164-164: Confirm “inactive deployment” logic
Replacing isNull(schema.release) with isNull(schema.deploymentVersion) changes how “inactive” deployments are determined. Double-check that this new condition correctly aligns with the updated data model's definition of inactivity.


187-192: Verify updated left join
References to the schema.deploymentVersion table and eq(schema.releaseJobTrigger.releaseId, schema.deploymentVersion.id) should be consistent with the rest of the data model. Confirm that these joins and ID references match the intended rows.


245-250: Consistent join with deployment version
Switching from schema.release.id to schema.deploymentVersion.id and matching it to schema.releaseJobTrigger.releaseId is a logical shift toward the new table. This change looks good to merge as part of the overall refactor.


300-305: Double-check filtering correctness
Filtering by eq(schema.deploymentVersion.deploymentId, deploymentId) refines results to the new schema. Verify that this correctly encloses all valid deployment versions and excludes extraneous data.

packages/job-dispatch/src/policies/gradual-rollout.ts (2)

30-30: Type update looks good.

The parameter type change from schema.Release to schema.DeploymentVersion properly reflects the revised data model being used across the codebase.


80-82: Join statement update looks good.

The SQL join has been correctly updated to reference schema.deploymentVersion instead of schema.release. This change is consistent with the broader refactoring effort to transition from Release to DeploymentVersion entities.

packages/api/src/router/release-deploy.ts (4)

4-4: Import consolidation looks good.

Good approach to consolidate multiple individual schema imports into a single namespace import. This makes imports more maintainable and consistent.


88-94: Schema references properly updated.

All references to schema entities have been correctly updated to use the SCHEMA namespace prefix.


102-104: DeploymentVersion reference correctly updated.

The transition from release to deploymentVersion is properly implemented, maintaining consistent naming throughout the codebase.


109-111: Environment schema reference updated correctly.

The reference to the environment schema has been properly updated to use the SCHEMA namespace.

packages/db/src/schema/job.ts (3)

49-49: Import change looks good.

Correctly updated the import to reference deploymentVersion instead of release, which aligns with the broader schema refactoring.


259-268: BuildVersionCondition function properly updated.

All references to release.version have been systematically updated to deploymentVersion.version in the various condition checks. The changes are thorough and consistent.


275-277: BuildCondition function correctly refactored.

The condition checks for JobFilterType.Deployment and JobFilterType.Release have been properly updated to use deploymentVersion properties instead of release properties.

Also applies to: 282-284

apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/resources/ReleaseCell.tsx (3)

3-3: Type import consolidation looks good.

Good approach to consolidate type imports using the namespace pattern, which is consistent with changes in other files.


18-20: ReleaseIcon component props properly updated.

The type annotation for the job prop has been correctly updated to use the SCHEMA namespace.


76-81: ReleaseCell component props correctly refactored.

The type annotations for the component props have been properly updated to use the SCHEMA namespace, including the change from Partial<Release> to Partial<SCHEMA.DeploymentVersion>, maintaining consistency with the schema changes.

apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowDiagram.tsx (2)

3-3: Import refactored to use a consolidated schema namespace.

The change to import all schema types as a namespace (SCHEMA) aligns with the broader refactoring effort to standardize schema imports across the codebase.


24-29: Type references properly updated to use the SCHEMA namespace.

The prop types have been correctly updated to use the SCHEMA namespace, including the transition from Release to DeploymentVersion, which aligns with the data model refactoring.

packages/job-dispatch/src/policies/success-rate-criteria-passing.ts (3)

13-13: Parameter type updated from Release to DeploymentVersion.

The parameter type change from schema.Release to schema.DeploymentVersion correctly implements the data model refactoring.


69-70: Join condition updated to use deploymentVersion instead of release.

The inner join condition has been correctly updated to use schema.deploymentVersion instead of schema.release, maintaining consistency with the updated parameter types.


94-94:

Details

✅ Verification successful

Verify reference to deployment_version in logic.

The result destructuring references policy.deployment_version, which appears to be correct, but ensure this matches the column alias defined in the query.


🏁 Script executed:

#!/bin/bash
# Check if the deployment_version alias is correctly used throughout the codebase
rg -A 5 -B 5 "deployment_version" --type=ts

Length of output: 55726


Deployment Version Alias Verified – No Changes Required

The verification confirms that the policy.deployment_version reference in the logic (specifically in packages/job-dispatch/src/policies/success-rate-criteria-passing.ts) consistently matches the column alias defined in the database queries. All occurrences across the codebase, including tests and related queries, use the alias correctly.

packages/api/src/router/release.ts (4)

21-21: Import refactored to use a consolidated schema namespace.

The change to import all schema entities as a namespace (SCHEMA) aligns with the broader refactoring effort to standardize schema imports across the codebase.


67-74: References properly updated to use SCHEMA namespace.

The query references have been correctly updated to use the SCHEMA namespace, including the transition from release to deploymentVersion for the deployment ID check and release condition matching.


178-178: Input type reference updated to use SCHEMA namespace.

The procedure's input type has been correctly updated from createRelease to SCHEMA.createRelease.


215-215: Update procedure's input type properly refactored.

The input type for the update procedure has been correctly updated to use SCHEMA.updateRelease.

apps/webservice/src/app/[workspaceSlug]/(app)/dependencies/DependencyDiagram.tsx (4)

3-3: Import refactored to use a consolidated schema namespace.

The change to import all schema types as a namespace (SCHEMA) aligns with the broader refactoring effort to standardize schema imports across the codebase.


106-106: Component prop type updated from Release to DeploymentVersion.

The releases prop type in the ReleaseSelector component has been correctly updated from Release[] to SCHEMA.DeploymentVersion[].


151-153: Node props type definition updated to use SCHEMA namespace.

The type definition for the DeploymentNode component has been correctly updated to use the SCHEMA namespace for the Deployment type.


227-229: Type definitions for deployments array updated correctly.

The type definitions for the deployments prop in both DependencyDiagram and Diagram components have been correctly updated to use the SCHEMA namespace.

Also applies to: 269-271

packages/db/src/schema/release.ts (7)

83-83: Foreign key reference update looks correct.

Ensures that releaseId now references deploymentVersion.id. This aligns with the renamed entity and maintains referential integrity.


106-131: New deploymentVersion table definition well-structured.

Declares fields consistently with the new naming conventions. Defaulting config and jobAgentConfig to {} seems correct; just confirm these defaults align with downstream usage.


133-133: Consistent type export.

Exporting DeploymentVersion here completes the rename from the old Release type. No concerns.


160-161: Foreign key reference aligns with the renamed table.

Points to deploymentVersion.id consistently.


235-235: Metadata references to deploymentVersion.id are correct.

These lines consistently change the reference from the old table to deploymentVersion. Logical consistency is evident.

Also applies to: 249-249, 264-264, 279-279, 294-294, 309-309


319-326:

Details

❓ Verification inconclusive

Date filtering logic seems correct; consider timezone implications.

These lines appear correct for basic comparisons, but confirm that new Date(cond.value) matches your intended timezone approach.


🏁 Script executed:

#!/bin/bash
# Checking references to 'AT TIME ZONE' to confirm thorough timezone handling
rg "AT TIME ZONE" -A5

Length of output: 2385


Review: Verify Timezone Consistency for Date Filtering

The date comparisons in the schema appear correct for basic filtering. However, note that while other parts of the codebase (e.g., in packages/api) apply explicit timezone adjustments using "AT TIME ZONE", this function relies on raw date comparisons. Please ensure that the use of constructs like new Date(cond.value) aligns with your intended timezone strategy. If the input dates should be normalized (e.g., converting to UTC) before comparison, then additional handling may be necessary.

  • Confirm that the timezone assumed when parsing cond.value (via new Date) matches the expectations from other modules.
  • Consider whether explicit timezone conversion should be added in this file to maintain consistency with the API router logic.

330-337:

Details

❓ Verification inconclusive

Version filtering logic appears correct; verify input sanitization.

ilike and regex usage look good. Drizzle usually parameterizes queries, but ensure cond.value is sanitized or validated to avoid injection edge cases.


🏁 Script executed:

#!/bin/bash
# Ensure `cond.value` is validated in code.
# Searching for buildVersionCondition references to confirm safe usage
rg -A 10 "buildVersionCondition"

Length of output: 3415


Ensure cond.value is safely validated

The version filtering logic correctly uses Drizzle’s parameterized functions (e.g., eq, ilike, and the sql template literal). However, as these functions rely on upstream input handling, please verify that any value assigned to cond.value is appropriately validated or sanitized—especially for regex operations (using ~) where injection risks may be subtler. Also, double-check that similar sanitization is in place in modules like packages/db/src/schema/job.ts.

packages/job-dispatch/src/policies/release-sequencing.ts (3)

37-38: Correct reference adjustments to deploymentVersion.

The join conditions are properly updated to point to schema.deploymentVersion. This is consistent with the renamed entity.

Also applies to: 42-42, 55-55


129-129: Join & ordering logic updated to deploymentVersion.

These lines correctly switch from the old release table to deploymentVersion and order by its createdAt field.

Also applies to: 132-132, 147-147, 155-155


180-181: Query referencing deploymentVersion is consistent.

All relevant conditions utilize the updated table name and field references properly.

packages/api/src/router/job.ts (6)

49-50: Inner joins now referencing deploymentVersion.

Switching from release to deploymentVersion is coherent with the rest of the refactor.

Also applies to: 54-54


233-234: Count query references updated correctly.

Using deploymentVersion in the join conditions is consistent with the schema rename.

Also applies to: 238-238


352-353: Daily count query for deployment references is correct.

The switch to deploymentVersion ensures accurate joins.

Also applies to: 357-357


418-418: Release ID check updated to deploymentVersion.id.

Keeps naming in sync and ensures correct row selection.


516-516: Dependency references updated.

releaseDependency.releaseIddeploymentVersion.id is a valid rename alignment.


782-782: Metadata keys query referencing deploymentVersion.

All changed references (.from(schema.deploymentVersion), eq(schema.releaseJobTrigger.releaseId, schema.deploymentVersion.id), and .where(eq(schema.deploymentVersion.id, input))) appear properly aligned with the new table name.

Also applies to: 785-785, 795-795

packages/api/src/router/deployment.ts (20)

16-16: Refactored Schema Import
The new consolidated import using import * as SCHEMA from "@ctrlplane/db/schema"; centralizes all schema references and simplifies maintenance. Please ensure that all previous individual schema imports have been removed from other parts of the code.


31-31: Updated Input Schema for Create Release Channel
Switching to .input(SCHEMA.createReleaseChannel) leverages the updated schema definitions. Verify that the underlying SCHEMA.createReleaseChannel matches the expected input structure for channel creation.


55-57: Consistent Use of Schema in Update Query
Updating the query with ctx.db.update(SCHEMA.releaseChannel)...where(eq(SCHEMA.releaseChannel.id, input.id)) ensures that the operation applies to the correct table and field. This change aligns with the refactored schema.


70-73: Deletion Operation Updated Using Schema Namespace
The mutation now deletes using SCHEMA.releaseChannel with a filtering condition on its id. This refactoring centralizes the table reference and should simplify future schema changes.


119-125: Fetching Release Channel by ID with Schema Reference
The query correctly uses eq(SCHEMA.releaseChannel.id, input) and joins related environment policy data. Ensure that the structure returned by the with clause remains compatible with components consuming this data.


163-166: Hook List Query Updated with Schema Namespace
Filtering the hooks using eq(SCHEMA.hook.scopeId, input) and eq(SCHEMA.hook.scopeType, "deployment") is consistent with the refactoring effort. Confirm that the join with the runhooks (and subsequently runbook) still produces the desired result set.


183-185: Retrieving Hook by ID Using Schema
The query for fetching a hook by its ID now appropriately applies the schema reference (SCHEMA.hook). Downstream usage should be reviewed to ensure it correctly handles any changes in the hook’s data structure.


199-208: Consistent Hook Creation Flow Using Schema References
Using .input(SCHEMA.createHook) together with subsequent transactions on SCHEMA.deployment, SCHEMA.hook, and SCHEMA.runbook establishes a uniform pattern. Please verify that the transaction maintains referential integrity, especially for the inserted runbook and runhook records.


249-256: Updated Hook Update Input Validation
The update procedure now validates its input against SCHEMA.updateHook, ensuring that the updated structure conforms to the new schema definitions. This change helps keep the data model consistent across operations.


268-289: Schema Consistency in Hook Update Transaction
Within the transaction, updating SCHEMA.hook and then fetching related deployment data via SCHEMA.deployment preserves integrity. The deletion of the previous runbook (using SCHEMA.runbook) before inserting new records ensures a clean state.


297-319: Recreating Associated Records in Hook Update
The insertion of a new runbook (and its optional variables) followed by creating a new runhook is properly using the consolidated schema namespace. Review that the transactional boundaries are sufficient to maintain atomicity across these operations.


330-332: Schema Consistency in Hook Delete Authorization Check
The authorization query now references SCHEMA.hook correctly when verifying a hook's existence and scope. This change is in line with the overall refactoring and simplifies future schema updates.


342-343: Hook Deletion Mutation with Schema Namespace
Using ctx.db.delete(SCHEMA.hook).where(eq(SCHEMA.hook.id, input)) for deletion aligns with the refactored import strategy. This reinforces the consistency in how schema entities are referenced across mutations.


360-372: Refactored Query for Latest Jobs Per Resource
The construction of the "latest_jobs" alias now leverages schema references (SCHEMA.job and SCHEMA.releaseJobTrigger) along with a window function for ranking. Ensure that the SQL expression using template literals is valid and performs as expected.


414-420: Deployment Creation with Updated Schema
Using .input(SCHEMA.createDeployment) and inserting into SCHEMA.deployment with a default empty string for a missing description ensures a smooth creation path. Confirm that the schema for deployments is comprehensive and up-to-date.


430-433: Deployment Update Procedure Consistency
The update procedure now validates its input via SCHEMA.updateDeployment and then invokes the external updateDeployment function. Please verify that the external function uses the correct schema references internally.


443-456: Deployment Deletion with Event Handling
This deletion mutation first retrieves deployment details using SCHEMA.deployment, then processes related events before deleting the record. Confirm that the event handling with getEventsForDeploymentRemoved remains compatible with the updated schema structures.


468-471: Retrieve Deployment by ID Using Schema
The simple query to fetch a deployment by its ID now consistently uses SCHEMA.deployment and should seamlessly integrate with downstream modules expecting the updated data format.


564-591: Group By and Join Logic in BySystemId Query
The query groups deployments by system and aggregates release channels while joining with SCHEMA.system and SCHEMA.releaseChannel. Confirm that the lodash chain operations (especially the uniqBy on channel id) correctly deduplicate channels according to the new schema.


711-716: Deployment ByWorkspaceId Query
The query correctly joins SCHEMA.deployment and SCHEMA.system and filters by workspaceId. Ensure that the workspace filtering logic reflects any schema changes made during the refactor.

@adityachoudhari26 adityachoudhari26 merged commit 57f0fd3 into main Mar 12, 2025
10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the more-deployment-version-refactor branch March 12, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant