mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: clean code
This commit is contained in:
53
apps/dokploy/drizzle/0049_dark_leopardon.sql
Normal file
53
apps/dokploy/drizzle/0049_dark_leopardon.sql
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
ALTER TYPE "domainType" ADD VALUE 'preview';--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "preview_deployments" (
|
||||||
|
"previewDeploymentId" text PRIMARY KEY NOT NULL,
|
||||||
|
"branch" text NOT NULL,
|
||||||
|
"pullRequestId" text NOT NULL,
|
||||||
|
"pullRequestNumber" text NOT NULL,
|
||||||
|
"pullRequestURL" text NOT NULL,
|
||||||
|
"pullRequestTitle" text NOT NULL,
|
||||||
|
"pullRequestCommentId" text NOT NULL,
|
||||||
|
"previewStatus" "applicationStatus" DEFAULT 'idle' NOT NULL,
|
||||||
|
"appName" text NOT NULL,
|
||||||
|
"applicationId" text NOT NULL,
|
||||||
|
"domainId" text,
|
||||||
|
"createdAt" text NOT NULL,
|
||||||
|
"expiresAt" text,
|
||||||
|
CONSTRAINT "preview_deployments_appName_unique" UNIQUE("appName")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "previewEnv" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "previewBuildArgs" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "previewWildcard" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "previewPort" integer DEFAULT 3000;--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "previewHttps" boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "previewPath" text DEFAULT '/';--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "certificateType" "certificateType" DEFAULT 'none' NOT NULL;--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "previewLimit" integer DEFAULT 3;--> statement-breakpoint
|
||||||
|
ALTER TABLE "application" ADD COLUMN "isPreviewDeploymentsActive" boolean DEFAULT false;--> statement-breakpoint
|
||||||
|
ALTER TABLE "domain" ADD COLUMN "previewDeploymentId" text;--> statement-breakpoint
|
||||||
|
ALTER TABLE "deployment" ADD COLUMN "isPreviewDeployment" boolean DEFAULT false;--> statement-breakpoint
|
||||||
|
ALTER TABLE "deployment" ADD COLUMN "previewDeploymentId" text;--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "preview_deployments" ADD CONSTRAINT "preview_deployments_applicationId_application_applicationId_fk" FOREIGN KEY ("applicationId") REFERENCES "public"."application"("applicationId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "preview_deployments" ADD CONSTRAINT "preview_deployments_domainId_domain_domainId_fk" FOREIGN KEY ("domainId") REFERENCES "public"."domain"("domainId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "domain" ADD CONSTRAINT "domain_previewDeploymentId_preview_deployments_previewDeploymentId_fk" FOREIGN KEY ("previewDeploymentId") REFERENCES "public"."preview_deployments"("previewDeploymentId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "deployment" ADD CONSTRAINT "deployment_previewDeploymentId_preview_deployments_previewDeploymentId_fk" FOREIGN KEY ("previewDeploymentId") REFERENCES "public"."preview_deployments"("previewDeploymentId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
@@ -1 +0,0 @@
|
|||||||
ALTER TABLE "application" ADD COLUMN "herokuVersion" text DEFAULT '24';
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "82e1398d-0f5d-4290-9cb2-fd812f096b28",
|
"id": "db518175-259d-4f4a-b6d0-fe95067bba61",
|
||||||
"prevId": "71016fed-2c39-4d31-aa33-0e0aceb313ef",
|
"prevId": "928417c8-2e7b-43ba-bc19-44b4d70107f1",
|
||||||
"version": "6",
|
"version": "6",
|
||||||
"dialect": "postgresql",
|
"dialect": "postgresql",
|
||||||
"tables": {
|
"tables": {
|
||||||
@@ -1199,13 +1199,6 @@
|
|||||||
"notNull": false,
|
"notNull": false,
|
||||||
"default": "'application'"
|
"default": "'application'"
|
||||||
},
|
},
|
||||||
"isPreviewDeployment": {
|
|
||||||
"name": "isPreviewDeployment",
|
|
||||||
"type": "boolean",
|
|
||||||
"primaryKey": false,
|
|
||||||
"notNull": false,
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
"uniqueConfigKey": {
|
"uniqueConfigKey": {
|
||||||
"name": "uniqueConfigKey",
|
"name": "uniqueConfigKey",
|
||||||
"type": "serial",
|
"type": "serial",
|
||||||
|
|||||||
@@ -348,8 +348,8 @@
|
|||||||
{
|
{
|
||||||
"idx": 49,
|
"idx": 49,
|
||||||
"version": "6",
|
"version": "6",
|
||||||
"when": 1733628466143,
|
"when": 1733628762978,
|
||||||
"tag": "0049_overrated_sage",
|
"tag": "0049_dark_leopardon",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ export default async function handler(
|
|||||||
} else if (req.headers["x-github-event"] === "pull_request") {
|
} else if (req.headers["x-github-event"] === "pull_request") {
|
||||||
const prId = githubBody?.pull_request?.id;
|
const prId = githubBody?.pull_request?.id;
|
||||||
|
|
||||||
console.log(githubBody);
|
|
||||||
if (githubBody?.action === "closed") {
|
if (githubBody?.action === "closed") {
|
||||||
const previewDeploymentResult =
|
const previewDeploymentResult =
|
||||||
await findPreviewDeploymentsByPullRequestId(prId);
|
await findPreviewDeploymentsByPullRequestId(prId);
|
||||||
@@ -187,6 +186,7 @@ export default async function handler(
|
|||||||
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;
|
||||||
|
const owner = githubBody?.repository?.owner?.login;
|
||||||
|
|
||||||
const apps = await db.query.applications.findMany({
|
const apps = await db.query.applications.findMany({
|
||||||
where: and(
|
where: and(
|
||||||
@@ -195,6 +195,7 @@ export default async function handler(
|
|||||||
eq(applications.repository, repository),
|
eq(applications.repository, repository),
|
||||||
eq(applications.branch, branch),
|
eq(applications.branch, branch),
|
||||||
eq(applications.isPreviewDeploymentsActive, true),
|
eq(applications.isPreviewDeploymentsActive, true),
|
||||||
|
eq(applications.owner, owner),
|
||||||
),
|
),
|
||||||
with: {
|
with: {
|
||||||
previewDeployments: true,
|
previewDeployments: true,
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ export const domains = pgTable("domain", {
|
|||||||
path: text("path").default("/"),
|
path: text("path").default("/"),
|
||||||
serviceName: text("serviceName"),
|
serviceName: text("serviceName"),
|
||||||
domainType: domainType("domainType").default("application"),
|
domainType: domainType("domainType").default("application"),
|
||||||
isPreviewDeployment: boolean("isPreviewDeployment").default(false), // TODO: remove
|
|
||||||
uniqueConfigKey: serial("uniqueConfigKey"),
|
uniqueConfigKey: serial("uniqueConfigKey"),
|
||||||
createdAt: text("createdAt")
|
createdAt: text("createdAt")
|
||||||
.notNull()
|
.notNull()
|
||||||
|
|||||||
Reference in New Issue
Block a user