diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/UpdateOverride.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/UpdateOverride.tsx index 64175929e..5c32d2a43 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/UpdateOverride.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-drawer/policy-override/UpdateOverride.tsx @@ -10,7 +10,7 @@ import { EnvironmentDrawerTab } from "../tabs"; import { useUpdateOverridePolicy } from "./useOverridePolicy"; type Deployment = SCHEMA.Deployment & { - releaseChannels: SCHEMA.ReleaseChannel[]; + releaseChannels: SCHEMA.DeploymentVersionChannel[]; }; type Policy = NonNullable< diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsx index d25a70ba8..5142e7788 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/environment-policy-drawer/EnvironmentPolicyDrawer.tsx @@ -116,7 +116,7 @@ const PolicyDropdownMenu: React.FC<{ type ViewProps = { environmentPolicy: SCHEMA.EnvironmentPolicy & { releaseWindows: SCHEMA.EnvironmentPolicyReleaseWindow[]; - releaseChannels: SCHEMA.ReleaseChannel[]; + releaseChannels: SCHEMA.DeploymentVersionChannel[]; }; activeTab: EnvironmentPolicyDrawerTab; }; diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx index 2fea83c31..ea9826205 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/policy-form-components/ReleaseChannels.tsx @@ -14,10 +14,10 @@ import { import { Popover, PopoverContent, PopoverTrigger } from "@ctrlplane/ui/popover"; type Deployment = SCHEMA.Deployment & { - releaseChannels: SCHEMA.ReleaseChannel[]; + releaseChannels: SCHEMA.DeploymentVersionChannel[]; }; -type Policy = { releaseChannels: SCHEMA.ReleaseChannel[] }; +type Policy = { releaseChannels: SCHEMA.DeploymentVersionChannel[] }; type DeploymentSelectProps = { deployment: Deployment; diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Overview.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Overview.tsx index f644eb398..6a16a6b8b 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Overview.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-channel-drawer/Overview.tsx @@ -38,7 +38,7 @@ import { useReleaseFilter } from "../release-condition/useReleaseFilter"; import { ReleaseBadgeList } from "../ReleaseBadgeList"; type OverviewProps = { - releaseChannel: SCHEMA.ReleaseChannel; + releaseChannel: SCHEMA.DeploymentVersionChannel; }; const getFinalFilter = (filter: ReleaseCondition | null) => diff --git a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-condition/ReleaseConditionDialog.tsx b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-condition/ReleaseConditionDialog.tsx index 74c0afb48..df19500bd 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-condition/ReleaseConditionDialog.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(app)/_components/release-condition/ReleaseConditionDialog.tsx @@ -43,7 +43,7 @@ type ReleaseConditionDialogProps = { condition: ReleaseCondition | null, releaseChannelId?: string | null, ) => void; - releaseChannels?: SCHEMA.ReleaseChannel[]; + releaseChannels?: SCHEMA.DeploymentVersionChannel[]; children: React.ReactNode; }; diff --git a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx index 697c327fc..35b708d29 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx @@ -175,7 +175,7 @@ type DeploymentPageContentProps = { deployment: Deployment; environments: schema.Environment[]; directories: { path: string; environments: schema.Environment[] }[]; - releaseChannel: schema.ReleaseChannel | null; + releaseChannel: schema.DeploymentVersionChannel | null; }; export const DeploymentPageContent: React.FC = ({ diff --git a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx index 6844d0ad9..c76072668 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(appv2)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/channels/ReleaseChannelsTable.tsx @@ -15,7 +15,7 @@ import { import { useReleaseChannelDrawer } from "~/app/[workspaceSlug]/(appv2)/_components/channel/drawer/useReleaseChannelDrawer"; import { ReleaseConditionBadge } from "~/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionBadge"; -type ReleaseChannel = SCHEMA.ReleaseChannel & { total: number }; +type ReleaseChannel = SCHEMA.DeploymentVersionChannel & { total: number }; type ReleaseChannelTableProps = { releaseChannels: ReleaseChannel[] }; diff --git a/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/channel/drawer/Overview.tsx b/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/channel/drawer/Overview.tsx index 6d8a2e2bd..7834dcfd0 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/channel/drawer/Overview.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/channel/drawer/Overview.tsx @@ -38,7 +38,7 @@ import { ReleaseBadgeList } from "~/app/[workspaceSlug]/(appv2)/_components/rele import { api } from "~/trpc/react"; type OverviewProps = { - releaseChannel: SCHEMA.ReleaseChannel; + releaseChannel: SCHEMA.DeploymentVersionChannel; }; const getFinalFilter = (filter: ReleaseCondition | null) => diff --git a/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionDialog.tsx b/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionDialog.tsx index 74c0afb48..df19500bd 100644 --- a/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionDialog.tsx +++ b/apps/webservice/src/app/[workspaceSlug]/(appv2)/_components/release/condition/ReleaseConditionDialog.tsx @@ -43,7 +43,7 @@ type ReleaseConditionDialogProps = { condition: ReleaseCondition | null, releaseChannelId?: string | null, ) => void; - releaseChannels?: SCHEMA.ReleaseChannel[]; + releaseChannels?: SCHEMA.DeploymentVersionChannel[]; children: React.ReactNode; }; diff --git a/apps/webservice/src/app/api/v1/deployments/[deploymentId]/release-channels/name/[name]/route.ts b/apps/webservice/src/app/api/v1/deployments/[deploymentId]/release-channels/name/[name]/route.ts index dac09e735..72526173c 100644 --- a/apps/webservice/src/app/api/v1/deployments/[deploymentId]/release-channels/name/[name]/route.ts +++ b/apps/webservice/src/app/api/v1/deployments/[deploymentId]/release-channels/name/[name]/route.ts @@ -20,11 +20,14 @@ export const DELETE = request() async (ctx, { params }) => { try { await ctx.db - .delete(schema.releaseChannel) + .delete(schema.deploymentVersionChannel) .where( and( - eq(schema.releaseChannel.deploymentId, params.deploymentId), - eq(schema.releaseChannel.name, params.name), + eq( + schema.deploymentVersionChannel.deploymentId, + params.deploymentId, + ), + eq(schema.deploymentVersionChannel.name, params.name), ), ); diff --git a/apps/webservice/src/app/api/v1/environments/route.ts b/apps/webservice/src/app/api/v1/environments/route.ts index 5c21c5f09..3ca6713a2 100644 --- a/apps/webservice/src/app/api/v1/environments/route.ts +++ b/apps/webservice/src/app/api/v1/environments/route.ts @@ -52,8 +52,8 @@ export const POST = request() const channels = await tx .select() - .from(schema.releaseChannel) - .where(inArray(schema.releaseChannel.id, releaseChannels)) + .from(schema.deploymentVersionChannel) + .where(inArray(schema.deploymentVersionChannel.id, releaseChannels)) .then((rows) => _.uniqBy(rows, (r) => r.deploymentId).map((r) => ({ channelId: r.id, diff --git a/apps/webservice/src/app/api/v1/release-channels/route.ts b/apps/webservice/src/app/api/v1/release-channels/route.ts index 5df28d0a7..595269be6 100644 --- a/apps/webservice/src/app/api/v1/release-channels/route.ts +++ b/apps/webservice/src/app/api/v1/release-channels/route.ts @@ -2,7 +2,7 @@ import type { z } from "zod"; import { NextResponse } from "next/server"; import { and, eq, takeFirst, takeFirstOrNull } from "@ctrlplane/db"; -import { createReleaseChannel } from "@ctrlplane/db/schema"; +import { createDeploymentVersionChannel } from "@ctrlplane/db/schema"; import * as SCHEMA from "@ctrlplane/db/schema"; import { Permission } from "@ctrlplane/validators/auth"; @@ -12,7 +12,7 @@ import { request } from "../middleware"; export const POST = request() .use(authn) - .use(parseBody(createReleaseChannel)) + .use(parseBody(createDeploymentVersionChannel)) .use( authz(({ ctx, can }) => can @@ -20,15 +20,15 @@ export const POST = request() .on({ type: "deployment", id: ctx.body.deploymentId }), ), ) - .handle<{ body: z.infer }>( + .handle<{ body: z.infer }>( async ({ db, body }) => { const releaseChannel = await db .select() - .from(SCHEMA.releaseChannel) + .from(SCHEMA.deploymentVersionChannel) .where( and( - eq(SCHEMA.releaseChannel.deploymentId, body.deploymentId), - eq(SCHEMA.releaseChannel.name, body.name), + eq(SCHEMA.deploymentVersionChannel.deploymentId, body.deploymentId), + eq(SCHEMA.deploymentVersionChannel.name, body.name), ), ) .then(takeFirstOrNull); @@ -40,7 +40,7 @@ export const POST = request() ); return db - .insert(SCHEMA.releaseChannel) + .insert(SCHEMA.deploymentVersionChannel) .values(body) .returning() .then(takeFirst) diff --git a/packages/api/src/router/deployment-version.ts b/packages/api/src/router/deployment-version.ts index d599addef..6d53dbfbb 100644 --- a/packages/api/src/router/deployment-version.ts +++ b/packages/api/src/router/deployment-version.ts @@ -254,18 +254,19 @@ export const versionRouter = createTRPCRouter({ .query(async ({ input }) => { const policyRCSubquery = db .select({ - releaseChannelId: SCHEMA.releaseChannel.id, + releaseChannelId: SCHEMA.deploymentVersionChannel.id, releaseChannelPolicyId: SCHEMA.environmentPolicyReleaseChannel.policyId, - releaseChannelDeploymentId: SCHEMA.releaseChannel.deploymentId, - releaseChannelFilter: SCHEMA.releaseChannel.releaseFilter, + releaseChannelDeploymentId: + SCHEMA.deploymentVersionChannel.deploymentId, + releaseChannelFilter: SCHEMA.deploymentVersionChannel.releaseFilter, }) .from(SCHEMA.environmentPolicyReleaseChannel) .innerJoin( - SCHEMA.releaseChannel, + SCHEMA.deploymentVersionChannel, eq( SCHEMA.environmentPolicyReleaseChannel.channelId, - SCHEMA.releaseChannel.id, + SCHEMA.deploymentVersionChannel.id, ), ) .as("policyRCSubquery"); @@ -588,10 +589,10 @@ export const versionRouter = createTRPCRouter({ ), ) .leftJoin( - SCHEMA.releaseChannel, + SCHEMA.deploymentVersionChannel, eq( SCHEMA.environmentPolicyReleaseChannel.channelId, - SCHEMA.releaseChannel.id, + SCHEMA.deploymentVersionChannel.id, ), ) .where(eq(SCHEMA.environment.id, environmentId)) diff --git a/packages/api/src/router/deployment.ts b/packages/api/src/router/deployment.ts index cff4eaddd..6ddaf285d 100644 --- a/packages/api/src/router/deployment.ts +++ b/packages/api/src/router/deployment.ts @@ -29,7 +29,7 @@ import { versionRouter } from "./deployment-version"; const releaseChannelRouter = createTRPCRouter({ create: protectedProcedure - .input(SCHEMA.createReleaseChannel) + .input(SCHEMA.createDeploymentVersionChannel) .meta({ authorizationCheck: ({ canUser, input }) => canUser.perform(Permission.ReleaseChannelCreate).on({ @@ -38,12 +38,15 @@ const releaseChannelRouter = createTRPCRouter({ }), }) .mutation(({ ctx, input }) => - ctx.db.insert(SCHEMA.releaseChannel).values(input).returning(), + ctx.db.insert(SCHEMA.deploymentVersionChannel).values(input).returning(), ), update: protectedProcedure .input( - z.object({ id: z.string().uuid(), data: SCHEMA.updateReleaseChannel }), + z.object({ + id: z.string().uuid(), + data: SCHEMA.updateDeploymentVersionChannel, + }), ) .meta({ authorizationCheck: ({ canUser, input }) => @@ -53,9 +56,9 @@ const releaseChannelRouter = createTRPCRouter({ }) .mutation(({ ctx, input }) => ctx.db - .update(SCHEMA.releaseChannel) + .update(SCHEMA.deploymentVersionChannel) .set(input.data) - .where(eq(SCHEMA.releaseChannel.id, input.id)) + .where(eq(SCHEMA.deploymentVersionChannel.id, input.id)) .returning(), ), @@ -69,8 +72,8 @@ const releaseChannelRouter = createTRPCRouter({ }) .mutation(({ ctx, input }) => ctx.db - .delete(SCHEMA.releaseChannel) - .where(eq(SCHEMA.releaseChannel.id, input)), + .delete(SCHEMA.deploymentVersionChannel) + .where(eq(SCHEMA.deploymentVersionChannel.id, input)), ), list: createTRPCRouter({ @@ -85,8 +88,8 @@ const releaseChannelRouter = createTRPCRouter({ .query(async ({ ctx, input }) => { const channels = await ctx.db .select() - .from(SCHEMA.releaseChannel) - .where(eq(SCHEMA.releaseChannel.deploymentId, input)); + .from(SCHEMA.deploymentVersionChannel) + .where(eq(SCHEMA.deploymentVersionChannel.deploymentId, input)); const promises = channels.map(async (channel) => { const filter = channel.releaseFilter ?? undefined; @@ -116,8 +119,8 @@ const releaseChannelRouter = createTRPCRouter({ .on({ type: "releaseChannel", id: input }), }) .query(async ({ ctx, input }) => { - const rc = await ctx.db.query.releaseChannel.findFirst({ - where: eq(SCHEMA.releaseChannel.id, input), + const rc = await ctx.db.query.deploymentVersionChannel.findFirst({ + where: eq(SCHEMA.deploymentVersionChannel.id, input), with: { environmentPolicyReleaseChannels: { with: { environmentPolicy: true }, @@ -530,8 +533,11 @@ export const deploymentRouter = createTRPCRouter({ eq(SCHEMA.jobAgent.id, SCHEMA.deployment.jobAgentId), ) .leftJoin( - SCHEMA.releaseChannel, - eq(SCHEMA.releaseChannel.deploymentId, SCHEMA.deployment.id), + SCHEMA.deploymentVersionChannel, + eq( + SCHEMA.deploymentVersionChannel.deploymentId, + SCHEMA.deployment.id, + ), ) .where( and( @@ -567,8 +573,11 @@ export const deploymentRouter = createTRPCRouter({ .select() .from(SCHEMA.deployment) .leftJoin( - SCHEMA.releaseChannel, - eq(SCHEMA.releaseChannel.deploymentId, SCHEMA.deployment.id), + SCHEMA.deploymentVersionChannel, + eq( + SCHEMA.deploymentVersionChannel.deploymentId, + SCHEMA.deployment.id, + ), ) .innerJoin( SCHEMA.system, diff --git a/packages/api/src/router/environment-policy.ts b/packages/api/src/router/environment-policy.ts index f5fbfecb7..c159f595a 100644 --- a/packages/api/src/router/environment-policy.ts +++ b/packages/api/src/router/environment-policy.ts @@ -14,12 +14,12 @@ import { import { createEnvironmentPolicy, createEnvironmentPolicyDeployment, + deploymentVersionChannel, environment, environmentPolicy, environmentPolicyDeployment, environmentPolicyReleaseChannel, environmentPolicyReleaseWindow, - releaseChannel, updateEnvironmentPolicy, } from "@ctrlplane/db/schema"; import { handleEnvironmentPolicyReleaseChannelUpdate } from "@ctrlplane/job-dispatch"; @@ -37,8 +37,11 @@ const basePolicyQuery = (db: Tx) => eq(environmentPolicyReleaseChannel.policyId, environmentPolicy.id), ) .leftJoin( - releaseChannel, - eq(environmentPolicyReleaseChannel.channelId, releaseChannel.id), + deploymentVersionChannel, + eq( + environmentPolicyReleaseChannel.channelId, + deploymentVersionChannel.id, + ), ) .leftJoin( environmentPolicyReleaseWindow, diff --git a/packages/api/src/router/environment.ts b/packages/api/src/router/environment.ts index 246f28310..c54102b66 100644 --- a/packages/api/src/router/environment.ts +++ b/packages/api/src/router/environment.ts @@ -16,12 +16,12 @@ import { } from "@ctrlplane/db"; import { createEnvironment, + deploymentVersionChannel, environment, environmentMetadata, environmentPolicy, environmentPolicyReleaseChannel, environmentPolicyReleaseWindow, - releaseChannel, resource, resourceMatchesMetadata, system, @@ -58,16 +58,19 @@ export const environmentRouter = createTRPCRouter({ const policyRCSubquery = ctx.db .select({ releaseChannelPolicyId: environmentPolicyReleaseChannel.policyId, - releaseChannelDeploymentId: releaseChannel.deploymentId, - releaseChannelDescription: releaseChannel.description, - releaseChannelFilter: releaseChannel.releaseFilter, - releaseChannelId: releaseChannel.id, - releaseChannelName: releaseChannel.name, + releaseChannelDeploymentId: deploymentVersionChannel.deploymentId, + releaseChannelDescription: deploymentVersionChannel.description, + releaseChannelFilter: deploymentVersionChannel.releaseFilter, + releaseChannelId: deploymentVersionChannel.id, + releaseChannelName: deploymentVersionChannel.name, }) .from(environmentPolicyReleaseChannel) .innerJoin( - releaseChannel, - eq(environmentPolicyReleaseChannel.channelId, releaseChannel.id), + deploymentVersionChannel, + eq( + environmentPolicyReleaseChannel.channelId, + deploymentVersionChannel.id, + ), ) .as("policyRCSubquery"); diff --git a/packages/auth/src/utils/rbac.ts b/packages/auth/src/utils/rbac.ts index e4fbb1604..b3f56f6fe 100644 --- a/packages/auth/src/utils/rbac.ts +++ b/packages/auth/src/utils/rbac.ts @@ -13,12 +13,12 @@ import { deployment, deploymentVariable, deploymentVersion, + deploymentVersionChannel, entityRole, environment, environmentPolicy, job, jobAgent, - releaseChannel, releaseJobTrigger, resource, resourceMetadataGroup, @@ -115,8 +115,11 @@ const getReleaseChannelScopes = async (id: string) => { .from(workspace) .innerJoin(system, eq(system.workspaceId, workspace.id)) .innerJoin(deployment, eq(deployment.systemId, system.id)) - .innerJoin(releaseChannel, eq(releaseChannel.deploymentId, deployment.id)) - .where(eq(releaseChannel.id, id)) + .innerJoin( + deploymentVersionChannel, + eq(deploymentVersionChannel.deploymentId, deployment.id), + ) + .where(eq(deploymentVersionChannel.id, id)) .then(takeFirst); return [ diff --git a/packages/db/src/schema/release-channel-relations.ts b/packages/db/src/schema/release-channel-relations.ts index 7ffc2fe00..ecb02cd04 100644 --- a/packages/db/src/schema/release-channel-relations.ts +++ b/packages/db/src/schema/release-channel-relations.ts @@ -2,10 +2,10 @@ import { relations } from "drizzle-orm"; import { environmentPolicy } from "./environment.js"; import { environmentPolicyReleaseChannel } from "./release-channel.js"; -import { releaseChannel } from "./release.js"; +import { deploymentVersionChannel } from "./release.js"; export const releaseChannelRelations = relations( - releaseChannel, + deploymentVersionChannel, ({ many }) => ({ environmentPolicyReleaseChannels: many(environmentPolicyReleaseChannel), }), @@ -18,9 +18,9 @@ export const environmentPolicyReleaseChannelRelations = relations( fields: [environmentPolicyReleaseChannel.policyId], references: [environmentPolicy.id], }), - releaseChannel: one(releaseChannel, { + releaseChannel: one(deploymentVersionChannel, { fields: [environmentPolicyReleaseChannel.channelId], - references: [releaseChannel.id], + references: [deploymentVersionChannel.id], }), }), ); diff --git a/packages/db/src/schema/release-channel.ts b/packages/db/src/schema/release-channel.ts index a42a0d6b6..4db130805 100644 --- a/packages/db/src/schema/release-channel.ts +++ b/packages/db/src/schema/release-channel.ts @@ -3,7 +3,7 @@ import { pgTable, uniqueIndex, uuid } from "drizzle-orm/pg-core"; import { deployment } from "./deployment.js"; import { environmentPolicy } from "./environment.js"; -import { releaseChannel } from "./release.js"; +import { deploymentVersionChannel } from "./release.js"; export const environmentPolicyReleaseChannel = pgTable( "environment_policy_deployment_version_channel", @@ -14,7 +14,7 @@ export const environmentPolicyReleaseChannel = pgTable( .references(() => environmentPolicy.id, { onDelete: "cascade" }), channelId: uuid("channel_id") .notNull() - .references(() => releaseChannel.id, { onDelete: "cascade" }), + .references(() => deploymentVersionChannel.id, { onDelete: "cascade" }), deploymentId: uuid("deployment_id") .notNull() .references(() => deployment.id, { onDelete: "cascade" }), diff --git a/packages/db/src/schema/release.ts b/packages/db/src/schema/release.ts index 2419ad50f..939254188 100644 --- a/packages/db/src/schema/release.ts +++ b/packages/db/src/schema/release.ts @@ -52,7 +52,7 @@ import { environment } from "./environment.js"; import { job } from "./job.js"; import { resource } from "./resource.js"; -export const releaseChannel = pgTable( +export const deploymentVersionChannel = pgTable( "deployment_version_channel", { id: uuid("id").primaryKey().defaultRandom(), @@ -68,11 +68,15 @@ export const releaseChannel = pgTable( (t) => ({ uniq: uniqueIndex().on(t.deploymentId, t.name) }), ); -export type ReleaseChannel = InferSelectModel; -export const createReleaseChannel = createInsertSchema(releaseChannel, { - releaseFilter: releaseCondition, -}).omit({ id: true }); -export const updateReleaseChannel = createReleaseChannel.partial(); +export type DeploymentVersionChannel = InferSelectModel< + typeof deploymentVersionChannel +>; +export const createDeploymentVersionChannel = createInsertSchema( + deploymentVersionChannel, + { releaseFilter: releaseCondition }, +).omit({ id: true }); +export const updateDeploymentVersionChannel = + createDeploymentVersionChannel.partial(); export const releaseDependency = pgTable( "deployment_version_dependency", diff --git a/packages/job-dispatch/src/environment-release-channel-update.ts b/packages/job-dispatch/src/environment-release-channel-update.ts index eb9c54dcd..108245513 100644 --- a/packages/job-dispatch/src/environment-release-channel-update.ts +++ b/packages/job-dispatch/src/environment-release-channel-update.ts @@ -21,8 +21,8 @@ const getReleaseFilter = (channelId: string | null) => channelId != null ? db .select() - .from(SCHEMA.releaseChannel) - .where(eq(SCHEMA.releaseChannel.id, channelId)) + .from(SCHEMA.deploymentVersionChannel) + .where(eq(SCHEMA.deploymentVersionChannel.id, channelId)) .then(takeFirstOrNull) .then((r) => r?.releaseFilter ?? null) : null; diff --git a/packages/job-dispatch/src/policies/release-sequencing.ts b/packages/job-dispatch/src/policies/release-sequencing.ts index 99f4a4986..d66eb0aec 100644 --- a/packages/job-dispatch/src/policies/release-sequencing.ts +++ b/packages/job-dispatch/src/policies/release-sequencing.ts @@ -91,14 +91,14 @@ const isReleaseLatestActiveForEnvironment = async ( const releaseChannelSubquery = db .select({ rcPolicyId: schema.environmentPolicyReleaseChannel.policyId, - rcReleaseFilter: schema.releaseChannel.releaseFilter, + rcReleaseFilter: schema.deploymentVersionChannel.releaseFilter, }) .from(schema.environmentPolicyReleaseChannel) .innerJoin( - schema.releaseChannel, + schema.deploymentVersionChannel, eq( schema.environmentPolicyReleaseChannel.channelId, - schema.releaseChannel.id, + schema.deploymentVersionChannel.id, ), ) .where( diff --git a/packages/job-dispatch/src/policies/release-string-check.ts b/packages/job-dispatch/src/policies/release-string-check.ts index ab5545965..3537ccc86 100644 --- a/packages/job-dispatch/src/policies/release-string-check.ts +++ b/packages/job-dispatch/src/policies/release-string-check.ts @@ -21,15 +21,15 @@ export const isPassingReleaseStringCheckPolicy: ReleasePolicyChecker = async ( const policyRCSubquery = db .select({ releaseChannelPolicyId: schema.environmentPolicyReleaseChannel.policyId, - releaseChannelDeploymentId: schema.releaseChannel.deploymentId, - releaseChannelFilter: schema.releaseChannel.releaseFilter, + releaseChannelDeploymentId: schema.deploymentVersionChannel.deploymentId, + releaseChannelFilter: schema.deploymentVersionChannel.releaseFilter, }) .from(schema.environmentPolicyReleaseChannel) .innerJoin( - schema.releaseChannel, + schema.deploymentVersionChannel, eq( schema.environmentPolicyReleaseChannel.channelId, - schema.releaseChannel.id, + schema.deploymentVersionChannel.id, ), ) .as("policyRCSubquery");