mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-31 17:22:16 +00:00
Add scheduleId to deployment schema and establish foreign key relationship
- Introduced a new column `scheduleId` in the `deployment` table to link deployments with schedules. - Added a foreign key constraint on `scheduleId` referencing the `schedule` table, ensuring referential integrity. - Updated the `deployment` schema to include the new relationship with the `schedules` table. - Enhanced the `schedules` schema to establish a one-to-many relationship with deployments.
This commit is contained in:
@@ -4,7 +4,7 @@ import { createInsertSchema } from "drizzle-zod";
|
||||
import { nanoid } from "nanoid";
|
||||
import { z } from "zod";
|
||||
import { applications } from "./application";
|
||||
|
||||
import { deployments } from "./deployment";
|
||||
export const schedules = pgTable("schedule", {
|
||||
scheduleId: text("scheduleId")
|
||||
.notNull()
|
||||
@@ -23,11 +23,12 @@ export const schedules = pgTable("schedule", {
|
||||
.$defaultFn(() => new Date().toISOString()),
|
||||
});
|
||||
|
||||
export const schedulesRelations = relations(schedules, ({ one }) => ({
|
||||
export const schedulesRelations = relations(schedules, ({ one, many }) => ({
|
||||
application: one(applications, {
|
||||
fields: [schedules.applicationId],
|
||||
references: [applications.applicationId],
|
||||
}),
|
||||
deployments: many(deployments),
|
||||
}));
|
||||
|
||||
export const createScheduleSchema = createInsertSchema(schedules, {
|
||||
|
||||
Reference in New Issue
Block a user