mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: migrate rest schemas
This commit is contained in:
parent
7c62408070
commit
0d525398a8
32
apps/dokploy/drizzle/0068_sour_professor_monster.sql
Normal file
32
apps/dokploy/drizzle/0068_sour_professor_monster.sql
Normal file
@ -0,0 +1,32 @@
|
||||
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 "ssh-key" 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 "ssh-key" DROP CONSTRAINT "ssh-key_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 "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 "ssh-key" ADD CONSTRAINT "ssh-key_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;
|
5278
apps/dokploy/drizzle/meta/0068_snapshot.json
Normal file
5278
apps/dokploy/drizzle/meta/0068_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -477,6 +477,13 @@
|
||||
"when": 1739427057545,
|
||||
"tag": "0067_migrate-data",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 68,
|
||||
"version": "7",
|
||||
"when": 1739428942964,
|
||||
"tag": "0068_sour_professor_monster",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
@ -25,9 +25,9 @@ export const certificates = pgTable("certificate", {
|
||||
// userId: text("userId").references(() => user.userId, {
|
||||
// onDelete: "cascade",
|
||||
// }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
serverId: text("serverId").references(() => server.serverId, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
@ -40,9 +40,9 @@ export const certificatesRelations = relations(
|
||||
fields: [certificates.serverId],
|
||||
references: [server.serverId],
|
||||
}),
|
||||
admin: one(admins, {
|
||||
fields: [certificates.adminId],
|
||||
references: [admins.adminId],
|
||||
user: one(users_temp, {
|
||||
fields: [certificates.userId],
|
||||
references: [users_temp.id],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
@ -24,9 +24,9 @@ export const destinations = pgTable("destination", {
|
||||
// userId: text("userId")
|
||||
// .notNull()
|
||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const destinationsRelations = relations(
|
||||
|
@ -29,9 +29,9 @@ export const gitProvider = pgTable("git_provider", {
|
||||
// userId: text("userId").references(() => user.userId, {
|
||||
// onDelete: "cascade",
|
||||
// }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const gitProviderRelations = relations(gitProvider, ({ one, many }) => ({
|
||||
|
@ -49,9 +49,9 @@ export const notifications = pgTable("notification", {
|
||||
// userId: text("userId").references(() => user.userId, {
|
||||
// onDelete: "cascade",
|
||||
// }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const slack = pgTable("slack", {
|
||||
@ -126,9 +126,9 @@ export const notificationsRelations = relations(notifications, ({ one }) => ({
|
||||
fields: [notifications.gotifyId],
|
||||
references: [gotify.gotifyId],
|
||||
}),
|
||||
admin: one(admins, {
|
||||
fields: [notifications.adminId],
|
||||
references: [admins.adminId],
|
||||
user: one(users_temp, {
|
||||
fields: [notifications.userId],
|
||||
references: [users_temp.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
|
@ -28,9 +28,9 @@ export const projects = pgTable("project", {
|
||||
// userId: text("userId")
|
||||
// .notNull()
|
||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
env: text("env").notNull().default(""),
|
||||
});
|
||||
|
||||
|
@ -32,9 +32,9 @@ export const registry = pgTable("registry", {
|
||||
// userId: text("userId")
|
||||
// .notNull()
|
||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const registryRelations = relations(registry, ({ one, many }) => ({
|
||||
|
@ -47,9 +47,9 @@ export const server = pgTable("server", {
|
||||
// userId: text("userId")
|
||||
// .notNull()
|
||||
// .references(() => user.userId, { onDelete: "cascade" }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
serverStatus: serverStatus("serverStatus").notNull().default("active"),
|
||||
command: text("command").notNull().default(""),
|
||||
sshKeyId: text("sshKeyId").references(() => sshKeys.sshKeyId, {
|
||||
|
@ -7,6 +7,7 @@ import { admins } from "./admin";
|
||||
import { applications } from "./application";
|
||||
import { compose } from "./compose";
|
||||
import { server } from "./server";
|
||||
import { users_temp } from "./user";
|
||||
// import { user } from "./user";
|
||||
|
||||
export const sshKeys = pgTable("ssh-key", {
|
||||
@ -25,19 +26,19 @@ export const sshKeys = pgTable("ssh-key", {
|
||||
// userId: text("userId").references(() => user.userId, {
|
||||
// onDelete: "cascade",
|
||||
// }),
|
||||
adminId: text("adminId")
|
||||
userId: text("userId")
|
||||
.notNull()
|
||||
.references(() => admins.adminId, { onDelete: "cascade" }),
|
||||
.references(() => users_temp.id, { onDelete: "cascade" }),
|
||||
});
|
||||
|
||||
export const sshKeysRelations = relations(sshKeys, ({ many, one }) => ({
|
||||
applications: many(applications),
|
||||
compose: many(compose),
|
||||
servers: many(server),
|
||||
// user: one(user, {
|
||||
// fields: [sshKeys.userId],
|
||||
// references: [user.id],
|
||||
// }),
|
||||
user: one(users_temp, {
|
||||
fields: [sshKeys.userId],
|
||||
references: [users_temp.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
const createSchema = createInsertSchema(
|
||||
|
@ -189,10 +189,10 @@ export const usersRelations = relations(users, ({ one }) => ({
|
||||
fields: [users.authId],
|
||||
references: [auth.id],
|
||||
}),
|
||||
admin: one(admins, {
|
||||
fields: [users.adminId],
|
||||
references: [admins.adminId],
|
||||
}),
|
||||
// admin: one(admins, {
|
||||
// fields: [users.adminId],
|
||||
// references: [admins.adminId],
|
||||
// }),
|
||||
}));
|
||||
|
||||
const createSchema = createInsertSchema(users, {
|
||||
|
Loading…
Reference in New Issue
Block a user