mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-18 03:02:56 +00:00
Changed the schedule scoping in the schedule utility to use organizationId instead of userId, ensuring that schedules are shared across all owners and admins within the same organization. This aligns with the recent changes to enhance organizational resource management.
29 lines
745 B
TypeScript
29 lines
745 B
TypeScript
import { schedules } from "@dokploy/server/db/schema";
|
|
import { eq } from "drizzle-orm";
|
|
import { db } from "../../db/index";
|
|
import { scheduleJob } from "./utils";
|
|
|
|
export const initSchedules = async () => {
|
|
try {
|
|
const schedulesResult = await db.query.schedules.findMany({
|
|
where: eq(schedules.enabled, true),
|
|
with: {
|
|
server: true,
|
|
application: true,
|
|
compose: true,
|
|
organization: true,
|
|
},
|
|
});
|
|
|
|
console.log(`Initializing ${schedulesResult.length} schedules`);
|
|
for (const schedule of schedulesResult) {
|
|
scheduleJob(schedule);
|
|
console.log(
|
|
`Initialized schedule: ${schedule.name} ${schedule.scheduleType} ✅`,
|
|
);
|
|
}
|
|
} catch (error) {
|
|
console.log(`Error initializing schedules: ${error}`);
|
|
}
|
|
};
|