mirror of
https://github.com/andwati/dokploy.git
synced 2026-12-03 08:18:46 +00:00
feat(database): add unique constraint to preview_deployments table and update schema
- Introduced a new SQL file to add a unique constraint on the combination of applicationId and pullRequestId in the preview_deployments table. - Updated the _journal.json to include the new migration entry for version 142. - Created a new snapshot file for version 142 to reflect the current database schema. - Modified the preview-deployments schema to include a unique index for applicationId and pullRequestId, enhancing data integrity.
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "preview_deployments" ADD CONSTRAINT "preview_deployments_applicationId_pullRequestId_unique" UNIQUE("applicationId","pullRequestId");
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -995,6 +995,13 @@
|
|||||||
"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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { relations } from "drizzle-orm";
|
import { relations } from "drizzle-orm";
|
||||||
import { pgTable, text } from "drizzle-orm/pg-core";
|
import { pgTable, text, unique } 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,35 +9,41 @@ import { domains } from "./domain";
|
|||||||
import { applicationStatus } from "./shared";
|
import { applicationStatus } from "./shared";
|
||||||
import { generateAppName } from "./utils";
|
import { generateAppName } from "./utils";
|
||||||
|
|
||||||
export const previewDeployments = pgTable("preview_deployments", {
|
export const previewDeployments = pgTable(
|
||||||
previewDeploymentId: text("previewDeploymentId")
|
"preview_deployments",
|
||||||
.notNull()
|
{
|
||||||
.primaryKey()
|
previewDeploymentId: text("previewDeploymentId")
|
||||||
.$defaultFn(() => nanoid()),
|
.notNull()
|
||||||
branch: text("branch").notNull(),
|
.primaryKey()
|
||||||
pullRequestId: text("pullRequestId").notNull(),
|
.$defaultFn(() => nanoid()),
|
||||||
pullRequestNumber: text("pullRequestNumber").notNull(),
|
branch: text("branch").notNull(),
|
||||||
pullRequestURL: text("pullRequestURL").notNull(),
|
pullRequestId: text("pullRequestId").notNull(),
|
||||||
pullRequestTitle: text("pullRequestTitle").notNull(),
|
pullRequestNumber: text("pullRequestNumber").notNull(),
|
||||||
pullRequestCommentId: text("pullRequestCommentId").notNull(),
|
pullRequestURL: text("pullRequestURL").notNull(),
|
||||||
previewStatus: applicationStatus("previewStatus").notNull().default("idle"),
|
pullRequestTitle: text("pullRequestTitle").notNull(),
|
||||||
appName: text("appName")
|
pullRequestCommentId: text("pullRequestCommentId").notNull(),
|
||||||
.notNull()
|
previewStatus: applicationStatus("previewStatus").notNull().default("idle"),
|
||||||
.$defaultFn(() => generateAppName("preview"))
|
appName: text("appName")
|
||||||
.unique(),
|
.notNull()
|
||||||
applicationId: text("applicationId")
|
.$defaultFn(() => generateAppName("preview"))
|
||||||
.notNull()
|
.unique(),
|
||||||
.references(() => applications.applicationId, {
|
applicationId: text("applicationId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => applications.applicationId, {
|
||||||
|
onDelete: "cascade",
|
||||||
|
}),
|
||||||
|
domainId: text("domainId").references(() => domains.domainId, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
domainId: text("domainId").references(() => domains.domainId, {
|
createdAt: text("createdAt")
|
||||||
onDelete: "cascade",
|
.notNull()
|
||||||
|
.$defaultFn(() => new Date().toISOString()),
|
||||||
|
expiresAt: text("expiresAt"),
|
||||||
|
},
|
||||||
|
(t) => ({
|
||||||
|
unqApplicationPullRequest: unique().on(t.applicationId, t.pullRequestId),
|
||||||
}),
|
}),
|
||||||
createdAt: text("createdAt")
|
);
|
||||||
.notNull()
|
|
||||||
.$defaultFn(() => new Date().toISOString()),
|
|
||||||
expiresAt: text("expiresAt"),
|
|
||||||
});
|
|
||||||
|
|
||||||
export const previewDeploymentsRelations = relations(
|
export const previewDeploymentsRelations = relations(
|
||||||
previewDeployments,
|
previewDeployments,
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ const { handler, api } = betterAuth({
|
|||||||
...(settings?.serverIp ? [`http://${settings?.serverIp}:3000`] : []),
|
...(settings?.serverIp ? [`http://${settings?.serverIp}:3000`] : []),
|
||||||
...(settings?.host ? [`https://${settings?.host}`] : []),
|
...(settings?.host ? [`https://${settings?.host}`] : []),
|
||||||
...(process.env.NODE_ENV === "development"
|
...(process.env.NODE_ENV === "development"
|
||||||
? ["http://localhost:3000"]
|
? [
|
||||||
|
"http://localhost:3000",
|
||||||
|
"https://absolutely-handy-falcon.ngrok-free.app",
|
||||||
|
]
|
||||||
: []),
|
: []),
|
||||||
...trustedOrigins,
|
...trustedOrigins,
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user