mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-06 22:45:24 +02:00
feat: implement rollback functionality with UI components and database schema updates
- Added ShowEnv and ShowRollbackSettings components for displaying and configuring rollback settings. - Implemented ShowRollbacks component to list and manage rollbacks for applications. - Created rollback database schema and updated application schema to include rollback settings. - Added API routes for managing rollbacks, including fetching, creating, and deleting rollbacks. - Integrated rollback functionality into the application deployment process.
This commit is contained in:
45
packages/server/src/db/schema/rollbacks.ts
Normal file
45
packages/server/src/db/schema/rollbacks.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { relations } from "drizzle-orm";
|
||||
import { pgTable, serial, text } from "drizzle-orm/pg-core";
|
||||
import { createInsertSchema } from "drizzle-zod";
|
||||
import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
import { applications } from "./application";
|
||||
|
||||
export const rollbacks = pgTable("rollback", {
|
||||
rollbackId: text("rollbackId")
|
||||
.notNull()
|
||||
.primaryKey()
|
||||
.$defaultFn(() => nanoid()),
|
||||
env: text("env"),
|
||||
applicationId: text("applicationId")
|
||||
.notNull()
|
||||
.references(() => applications.applicationId, {
|
||||
onDelete: "cascade",
|
||||
}),
|
||||
version: serial(),
|
||||
image: text("image"),
|
||||
createdAt: text("createdAt")
|
||||
.notNull()
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
});
|
||||
|
||||
export type Rollback = typeof rollbacks.$inferSelect;
|
||||
|
||||
export const rollbacksRelations = relations(rollbacks, ({ one }) => ({
|
||||
application: one(applications, {
|
||||
fields: [rollbacks.applicationId],
|
||||
references: [applications.applicationId],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const createRollbackSchema = createInsertSchema(rollbacks).extend({
|
||||
appName: z.string().min(1),
|
||||
});
|
||||
|
||||
export const updateRollbackSchema = createRollbackSchema.extend({
|
||||
rollbackId: z.string().min(1),
|
||||
});
|
||||
|
||||
export const apiFindOneRollback = z.object({
|
||||
rollbackId: z.string().min(1),
|
||||
});
|
||||
Reference in New Issue
Block a user