refactor(database): remove unique constraint and related files for preview_deployments

- Deleted the SQL file that added a unique constraint on the combination of applicationId and pullRequestId in the preview_deployments table.
- Removed the corresponding entry from the _journal.json to reflect the deletion of the migration.
- Deleted the snapshot file for version 142, which is no longer needed.
- Updated the preview-deployments schema to remove the unique index, reverting to the previous state.
This commit is contained in:
Mauricio Siu
2026-02-08 01:51:02 -06:00
parent 51095e3ac5
commit a212d42495
5 changed files with 49 additions and 7312 deletions
@@ -1 +0,0 @@
ALTER TABLE "preview_deployments" ADD CONSTRAINT "preview_deployments_applicationId_pullRequestId_unique" UNIQUE("applicationId","pullRequestId");
File diff suppressed because it is too large Load Diff
-7
View File
@@ -995,13 +995,6 @@
"when": 1770490719123, "when": 1770490719123,
"tag": "0141_plain_earthquake", "tag": "0141_plain_earthquake",
"breakpoints": true "breakpoints": true
},
{
"idx": 142,
"version": "7",
"when": 1770535594423,
"tag": "0142_loose_warpath",
"breakpoints": true
} }
] ]
} }
+8 -1
View File
@@ -355,6 +355,11 @@ export default async function handler(
action === "labeled" || action === "labeled" ||
action === "unlabeled" action === "unlabeled"
) { ) {
const shouldCreateDeployment =
action === "opened" ||
action === "synchronize" ||
action === "reopened";
const repository = githubBody?.repository?.name; const repository = githubBody?.repository?.name;
const deploymentHash = githubBody?.pull_request?.head?.sha; const deploymentHash = githubBody?.pull_request?.head?.sha;
const branch = githubBody?.pull_request?.base?.ref; const branch = githubBody?.pull_request?.base?.ref;
@@ -475,7 +480,7 @@ export default async function handler(
let previewDeploymentId = let previewDeploymentId =
previewDeploymentResult?.previewDeploymentId || ""; previewDeploymentResult?.previewDeploymentId || "";
if (!previewDeploymentResult) { if (!previewDeploymentResult && shouldCreateDeployment) {
const previewDeployment = await createPreviewDeployment({ const previewDeployment = await createPreviewDeployment({
applicationId: app.applicationId as string, applicationId: app.applicationId as string,
branch: prBranch, branch: prBranch,
@@ -497,6 +502,7 @@ export default async function handler(
previewDeploymentId, previewDeploymentId,
}; };
if (previewDeploymentId) {
if (IS_CLOUD && app.serverId) { if (IS_CLOUD && app.serverId) {
jobData.serverId = app.serverId; jobData.serverId = app.serverId;
deploy(jobData).catch((error) => { deploy(jobData).catch((error) => {
@@ -513,6 +519,7 @@ export default async function handler(
}, },
); );
} }
}
return res.status(200).json({ message: "Apps Deployed" }); return res.status(200).json({ message: "Apps Deployed" });
} }
} }
@@ -1,5 +1,5 @@
import { relations } from "drizzle-orm"; import { relations } from "drizzle-orm";
import { pgTable, text, unique } from "drizzle-orm/pg-core"; import { pgTable, text } from "drizzle-orm/pg-core";
import { createInsertSchema } from "drizzle-zod"; import { createInsertSchema } from "drizzle-zod";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { z } from "zod"; import { z } from "zod";
@@ -9,9 +9,7 @@ import { domains } from "./domain";
import { applicationStatus } from "./shared"; import { applicationStatus } from "./shared";
import { generateAppName } from "./utils"; import { generateAppName } from "./utils";
export const previewDeployments = pgTable( export const previewDeployments = pgTable("preview_deployments", {
"preview_deployments",
{
previewDeploymentId: text("previewDeploymentId") previewDeploymentId: text("previewDeploymentId")
.notNull() .notNull()
.primaryKey() .primaryKey()
@@ -39,11 +37,7 @@ export const previewDeployments = pgTable(
.notNull() .notNull()
.$defaultFn(() => new Date().toISOString()), .$defaultFn(() => new Date().toISOString()),
expiresAt: text("expiresAt"), expiresAt: text("expiresAt"),
}, });
(t) => ({
unqApplicationPullRequest: unique().on(t.applicationId, t.pullRequestId),
}),
);
export const previewDeploymentsRelations = relations( export const previewDeploymentsRelations = relations(
previewDeployments, previewDeployments,