-
Notifications
You must be signed in to change notification settings - Fork 11
release channels policy #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,6 +48,18 @@ import { environment } from "./environment.js"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| import { job } from "./job.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { target } from "./target.js"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| export const releaseChannel = pgTable("release_channel", { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| id: uuid("id").primaryKey().defaultRandom(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| name: text("name").notNull(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| description: text("description").default(""), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| deploymentId: uuid("deployment_id") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .notNull() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .references(() => deployment.id, { onDelete: "cascade" }), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| releaseFilter: jsonb("release_filter") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .$type<ReleaseCondition | null>() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| .default(sql`NULL`), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+51
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding uniqueness constraint for channel names within a deployment. The current schema allows duplicate channel names within the same deployment, which could lead to confusion. Consider adding a unique index on (deploymentId, name). export const releaseChannel = pgTable("release_channel", {
id: uuid("id").primaryKey().defaultRandom(),
name: text("name").notNull(),
description: text("description").default(""),
deploymentId: uuid("deployment_id")
.notNull()
.references(() => deployment.id, { onDelete: "cascade" }),
releaseFilter: jsonb("release_filter")
.$type<ReleaseCondition | null>()
.default(sql`NULL`),
- });
+ }, (t) => ({
+ unq: uniqueIndex().on(t.deploymentId, t.name)
+ }));📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| export const releaseDependency = pgTable( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| "release_dependency", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix incorrect field reference in unique index
customPolicyUniqThe unique index
customPolicyUniqreferencesis_own_policy, which is not defined in theenvironmentPolicyDeploymenttable. The correct field ishasCustomPolicy. Update theWHEREclause to usehasCustomPolicyinstead to ensure the index functions as intended.Apply this diff to correct the field reference:
(t) => ({ customPolicyUniq: uniqueIndex() .on(t.environmentId) - .where(sql`is_own_policy = true`), + .where(sql`has_custom_policy = true`), uniq: uniqueIndex().on(t.policyId, t.environmentId), }),📝 Committable suggestion