From 7c624080704134999fb5325ae1739339337b4be6 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 13 Feb 2025 00:38:39 -0600 Subject: [PATCH] refactor: delete --- apps/dokploy/drizzle/0066_smiling_warlock.sql | 153 ------------------ apps/dokploy/migrate.ts | 2 +- packages/server/src/db/schema/account.ts | 2 +- packages/server/src/db/schema/certificate.ts | 4 +- packages/server/src/db/schema/project.ts | 2 +- packages/server/src/db/schema/server.ts | 2 +- packages/server/src/db/schema/session.ts | 2 +- 7 files changed, 7 insertions(+), 160 deletions(-) delete mode 100644 apps/dokploy/drizzle/0066_smiling_warlock.sql diff --git a/apps/dokploy/drizzle/0066_smiling_warlock.sql b/apps/dokploy/drizzle/0066_smiling_warlock.sql deleted file mode 100644 index 9deea8818..000000000 --- a/apps/dokploy/drizzle/0066_smiling_warlock.sql +++ /dev/null @@ -1,153 +0,0 @@ -CREATE TABLE "user_temp" ( - "id" text PRIMARY KEY NOT NULL, - "name" text DEFAULT '' NOT NULL, - "token" text NOT NULL, - "isRegistered" boolean DEFAULT false NOT NULL, - "expirationDate" text NOT NULL, - "createdAt" text NOT NULL, - "canCreateProjects" boolean DEFAULT false NOT NULL, - "canAccessToSSHKeys" boolean DEFAULT false NOT NULL, - "canCreateServices" boolean DEFAULT false NOT NULL, - "canDeleteProjects" boolean DEFAULT false NOT NULL, - "canDeleteServices" boolean DEFAULT false NOT NULL, - "canAccessToDocker" boolean DEFAULT false NOT NULL, - "canAccessToAPI" boolean DEFAULT false NOT NULL, - "canAccessToGitProviders" boolean DEFAULT false NOT NULL, - "canAccessToTraefikFiles" boolean DEFAULT false NOT NULL, - "accesedProjects" text[] DEFAULT ARRAY[]::text[] NOT NULL, - "accesedServices" text[] DEFAULT ARRAY[]::text[] NOT NULL, - "email" text NOT NULL, - "email_verified" boolean NOT NULL, - "image" text, - "role" text, - "banned" boolean, - "ban_reason" text, - "ban_expires" timestamp, - "updated_at" timestamp NOT NULL, - "serverIp" text, - "certificateType" "certificateType" DEFAULT 'none' NOT NULL, - "host" text, - "letsEncryptEmail" text, - "sshPrivateKey" text, - "enableDockerCleanup" boolean DEFAULT false NOT NULL, - "enableLogRotation" boolean DEFAULT false NOT NULL, - "enablePaidFeatures" boolean DEFAULT false NOT NULL, - "metricsConfig" jsonb DEFAULT '{"server":{"type":"Dokploy","refreshRate":60,"port":4500,"token":"","retentionDays":2,"cronJob":"","urlCallback":"","thresholds":{"cpu":0,"memory":0}},"containers":{"refreshRate":60,"services":{"include":[],"exclude":[]}}}'::jsonb NOT NULL, - "cleanupCacheApplications" boolean DEFAULT false NOT NULL, - "cleanupCacheOnPreviews" boolean DEFAULT false NOT NULL, - "cleanupCacheOnCompose" boolean DEFAULT false NOT NULL, - "stripeCustomerId" text, - "stripeSubscriptionId" text, - "serversQuantity" integer DEFAULT 0 NOT NULL, - CONSTRAINT "user_temp_email_unique" UNIQUE("email") -); ---> statement-breakpoint -CREATE TABLE "session_temp" ( - "id" text PRIMARY KEY NOT NULL, - "expires_at" timestamp NOT NULL, - "token" text NOT NULL, - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, - "ip_address" text, - "user_agent" text, - "user_id" text NOT NULL, - "impersonated_by" text, - "active_organization_id" text, - CONSTRAINT "session_temp_token_unique" UNIQUE("token") -); ---> statement-breakpoint -CREATE TABLE "account" ( - "id" text PRIMARY KEY NOT NULL, - "account_id" text NOT NULL, - "provider_id" text NOT NULL, - "user_id" text NOT NULL, - "access_token" text, - "refresh_token" text, - "id_token" text, - "access_token_expires_at" timestamp, - "refresh_token_expires_at" timestamp, - "scope" text, - "password" text, - "is2FAEnabled" boolean DEFAULT false NOT NULL, - "created_at" timestamp NOT NULL, - "updated_at" timestamp NOT NULL, - "resetPasswordToken" text, - "resetPasswordExpiresAt" text, - "confirmationToken" text, - "confirmationExpiresAt" text -); ---> statement-breakpoint -CREATE TABLE "invitation" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "email" text NOT NULL, - "role" text, - "status" text NOT NULL, - "expires_at" timestamp NOT NULL, - "inviter_id" text NOT NULL -); ---> statement-breakpoint -CREATE TABLE "member" ( - "id" text PRIMARY KEY NOT NULL, - "organization_id" text NOT NULL, - "user_id" text NOT NULL, - "role" text NOT NULL, - "created_at" timestamp NOT NULL -); ---> statement-breakpoint -CREATE TABLE "organization" ( - "id" text PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "slug" text, - "logo" text, - "created_at" timestamp NOT NULL, - "metadata" text, - "owner_id" text NOT NULL, - CONSTRAINT "organization_slug_unique" UNIQUE("slug") -); ---> statement-breakpoint -CREATE TABLE "verification" ( - "id" text PRIMARY KEY NOT NULL, - "identifier" text NOT NULL, - "value" text NOT NULL, - "expires_at" timestamp NOT NULL, - "created_at" timestamp, - "updated_at" timestamp -); ---> statement-breakpoint -ALTER TABLE "project" RENAME COLUMN "adminId" TO "userId";--> statement-breakpoint -ALTER TABLE "destination" RENAME COLUMN "adminId" TO "userId";--> statement-breakpoint -ALTER TABLE "certificate" RENAME COLUMN "adminId" TO "userId";--> statement-breakpoint -ALTER TABLE "registry" RENAME COLUMN "adminId" TO "userId";--> statement-breakpoint -ALTER TABLE "notification" RENAME COLUMN "adminId" TO "userId";--> statement-breakpoint -ALTER TABLE "git_provider" RENAME COLUMN "adminId" TO "userId";--> statement-breakpoint -ALTER TABLE "server" RENAME COLUMN "adminId" TO "userId";--> statement-breakpoint -ALTER TABLE "project" DROP CONSTRAINT "project_adminId_admin_adminId_fk"; ---> statement-breakpoint -ALTER TABLE "destination" DROP CONSTRAINT "destination_adminId_admin_adminId_fk"; ---> statement-breakpoint -ALTER TABLE "certificate" DROP CONSTRAINT "certificate_adminId_admin_adminId_fk"; ---> statement-breakpoint -ALTER TABLE "registry" DROP CONSTRAINT "registry_adminId_admin_adminId_fk"; ---> statement-breakpoint -ALTER TABLE "notification" DROP CONSTRAINT "notification_adminId_admin_adminId_fk"; ---> statement-breakpoint -ALTER TABLE "git_provider" DROP CONSTRAINT "git_provider_adminId_admin_adminId_fk"; ---> statement-breakpoint -ALTER TABLE "server" DROP CONSTRAINT "server_adminId_admin_adminId_fk"; ---> statement-breakpoint -ALTER TABLE "ssh-key" ALTER COLUMN "adminId" SET NOT NULL;--> statement-breakpoint -ALTER TABLE "session_temp" ADD CONSTRAINT "session_temp_user_id_user_temp_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user_temp"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_temp_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user_temp"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "invitation" ADD CONSTRAINT "invitation_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "invitation" ADD CONSTRAINT "invitation_inviter_id_user_temp_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."user_temp"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "member" ADD CONSTRAINT "member_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "member" ADD CONSTRAINT "member_user_id_user_temp_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user_temp"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "organization" ADD CONSTRAINT "organization_owner_id_user_temp_id_fk" FOREIGN KEY ("owner_id") REFERENCES "public"."user_temp"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "project" ADD CONSTRAINT "project_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "destination" ADD CONSTRAINT "destination_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "certificate" ADD CONSTRAINT "certificate_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "registry" ADD CONSTRAINT "registry_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "notification" ADD CONSTRAINT "notification_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "git_provider" ADD CONSTRAINT "git_provider_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "server" ADD CONSTRAINT "server_userId_user_temp_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user_temp"("id") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/apps/dokploy/migrate.ts b/apps/dokploy/migrate.ts index 72bbf2ab0..bcbac2336 100644 --- a/apps/dokploy/migrate.ts +++ b/apps/dokploy/migrate.ts @@ -1,8 +1,8 @@ import { drizzle } from "drizzle-orm/postgres-js"; import { migrate } from "drizzle-orm/postgres-js/migrator"; +import { nanoid } from "nanoid"; import postgres from "postgres"; import * as schema from "./server/db/schema"; -import { nanoid } from "nanoid"; const connectionString = process.env.DATABASE_URL!; diff --git a/packages/server/src/db/schema/account.ts b/packages/server/src/db/schema/account.ts index 349428fd8..3e81fbf69 100644 --- a/packages/server/src/db/schema/account.ts +++ b/packages/server/src/db/schema/account.ts @@ -1,6 +1,6 @@ import { boolean, pgTable, text, timestamp } from "drizzle-orm/pg-core"; -import { users_temp } from "./user"; import { nanoid } from "nanoid"; +import { users_temp } from "./user"; export const account = pgTable("account", { id: text("id") diff --git a/packages/server/src/db/schema/certificate.ts b/packages/server/src/db/schema/certificate.ts index bbdb1915d..02b00f65e 100644 --- a/packages/server/src/db/schema/certificate.ts +++ b/packages/server/src/db/schema/certificate.ts @@ -3,11 +3,11 @@ import { boolean, pgTable, text } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; +import { admins } from "./admin"; import { server } from "./server"; +import { users_temp } from "./user"; // import { user } from "./user"; import { generateAppName } from "./utils"; -import { admins } from "./admin"; -import { users_temp } from "./user"; export const certificates = pgTable("certificate", { certificateId: text("certificateId") diff --git a/packages/server/src/db/schema/project.ts b/packages/server/src/db/schema/project.ts index e352e47fb..48effa81c 100644 --- a/packages/server/src/db/schema/project.ts +++ b/packages/server/src/db/schema/project.ts @@ -4,6 +4,7 @@ import { pgTable, text } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import { nanoid } from "nanoid"; import { z } from "zod"; +import { admins } from "./admin"; // import { admins } from "./admin"; import { applications } from "./application"; import { compose } from "./compose"; @@ -13,7 +14,6 @@ import { mysql } from "./mysql"; import { postgres } from "./postgres"; import { redis } from "./redis"; import { users, users_temp } from "./user"; -import { admins } from "./admin"; export const projects = pgTable("project", { projectId: text("projectId") diff --git a/packages/server/src/db/schema/server.ts b/packages/server/src/db/schema/server.ts index ee1083bd6..c0b44ef97 100644 --- a/packages/server/src/db/schema/server.ts +++ b/packages/server/src/db/schema/server.ts @@ -22,9 +22,9 @@ import { mysql } from "./mysql"; import { postgres } from "./postgres"; import { redis } from "./redis"; import { sshKeys } from "./ssh-key"; +import { users_temp } from "./user"; // import { user } from "./user"; import { generateAppName } from "./utils"; -import { users_temp } from "./user"; export const serverStatus = pgEnum("serverStatus", ["active", "inactive"]); diff --git a/packages/server/src/db/schema/session.ts b/packages/server/src/db/schema/session.ts index 03a70c41a..4e9d28835 100644 --- a/packages/server/src/db/schema/session.ts +++ b/packages/server/src/db/schema/session.ts @@ -1,7 +1,7 @@ import { sql } from "drizzle-orm"; import { pgTable, text, timestamp } from "drizzle-orm/pg-core"; -import { users_temp } from "./user"; import { auth } from "./auth"; +import { users_temp } from "./user"; // OLD TABLE export const session = pgTable("session_temp", {