diff --git a/backend/src/controllers/shiftTemplateController.ts b/backend/src/controllers/shiftTemplateController.ts index 8d1ce57..6a56fca 100644 --- a/backend/src/controllers/shiftTemplateController.ts +++ b/backend/src/controllers/shiftTemplateController.ts @@ -3,9 +3,6 @@ import { Request, Response } from 'express'; import { v4 as uuidv4 } from 'uuid'; import { db } from '../services/databaseService.js'; import { - ShiftTemplate, - TemplateShiftSlot, - TemplateShiftTimeRange, CreateShiftTemplateRequest, UpdateShiftTemplateRequest } from '../models/ShiftTemplate.js'; @@ -233,7 +230,7 @@ export const createTemplate = async (req: Request, res: Response): Promise await db.run( `INSERT INTO template_time_slots (id, template_id, name, start_time, end_time, description) VALUES (?, ?, ?, ?, ?, ?)`, - [timeSlotId, templateId, timeSlot.name, timeSlot.startTime, timeSlot.endTime, timeSlot.description] + [timeSlotId, templateId, timeSlot.name, timeSlot.startTime, timeSlot.endTime, description] ); } @@ -316,7 +313,7 @@ export const updateTemplate = async (req: Request, res: Response): Promise await db.run( `INSERT INTO template_time_slots (id, template_id, name, start_time, end_time, description) VALUES (?, ?, ?, ?, ?, ?)`, - [timeSlotId, id, timeSlot.name, timeSlot.startTime, timeSlot.endTime, timeSlot.description] + [timeSlotId, id, timeSlot.name, timeSlot.startTime, timeSlot.endTime, description] ); } } diff --git a/backend/src/database/migrations/002_add_employee_fields.sql b/backend/src/database/migrations/002_add_employee_fields.sql deleted file mode 100644 index bec67e1..0000000 --- a/backend/src/database/migrations/002_add_employee_fields.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Add employee fields -ALTER TABLE users ADD COLUMN employee_type TEXT CHECK(employee_type IN ('chef', 'neuling', 'erfahren')); -ALTER TABLE users ADD COLUMN is_sufficiently_independent BOOLEAN DEFAULT FALSE; -ALTER TABLE users ADD COLUMN last_login TEXT DEFAULT NULL; \ No newline at end of file diff --git a/backend/src/database/migrations/003_add_shift_name.sql b/backend/src/database/migrations/003_add_shift_name.sql deleted file mode 100644 index f555732..0000000 --- a/backend/src/database/migrations/003_add_shift_name.sql +++ /dev/null @@ -1,2 +0,0 @@ --- backend/src/database/migrations/003_add_shift_name.sql -ALTER TABLE assigned_shifts ADD COLUMN name TEXT; \ No newline at end of file diff --git a/backend/src/database/schema.sql b/backend/src/database/schema.sql index 34dbc17..c570892 100644 --- a/backend/src/database/schema.sql +++ b/backend/src/database/schema.sql @@ -27,11 +27,21 @@ CREATE TABLE IF NOT EXISTS shift_templates ( CREATE TABLE IF NOT EXISTS template_shifts ( id TEXT PRIMARY KEY, template_id TEXT NOT NULL, + time_range_id TEXT NOT NULL, day_of_week INTEGER NOT NULL CHECK (day_of_week >= 1 AND day_of_week <= 7), + required_employees INTEGER DEFAULT 1, + color TEXT DEFAULT '#3498db', + FOREIGN KEY (template_id) REFERENCES shift_templates(id) ON DELETE CASCADE, + FOREIGN KEY (time_range_id) REFERENCES template_time_slots(id) ON DELETE CASCADE +); + +-- Tabelle für Zeitbereiche in den Vorlagen +CREATE TABLE IF NOT EXISTS template_time_slots ( + id TEXT PRIMARY KEY, + template_id TEXT NOT NULL, name TEXT NOT NULL, start_time TEXT NOT NULL, end_time TEXT NOT NULL, - required_employees INTEGER DEFAULT 1, FOREIGN KEY (template_id) REFERENCES shift_templates(id) ON DELETE CASCADE ); diff --git a/backend/src/models/ShiftTemplate.ts b/backend/src/models/ShiftTemplate.ts index 3416554..52582a8 100644 --- a/backend/src/models/ShiftTemplate.ts +++ b/backend/src/models/ShiftTemplate.ts @@ -11,6 +11,7 @@ export interface TemplateShift { export interface TemplateShiftSlot { id: string; + templateId: string; dayOfWeek: number; timeRange: TemplateShiftTimeRange; requiredEmployees: number; @@ -28,14 +29,14 @@ export interface CreateShiftTemplateRequest { name: string; description?: string; isDefault: boolean; - shifts: Omit[]; - timeSlots: Omit[]; + shifts: Omit[]; + timeSlots: TemplateShiftTimeRange[]; } export interface UpdateShiftTemplateRequest { name?: string; description?: string; isDefault?: boolean; - shifts?: Omit[]; - timeSlots?: Omit[]; + shifts?: Omit[]; + timeSlots?: TemplateShiftTimeRange[]; } \ No newline at end of file