removed users table relicts

This commit is contained in:
2025-10-12 17:27:07 +02:00
parent 90d8ae5140
commit 142bee1cf9
13 changed files with 254 additions and 209 deletions

View File

@@ -8,7 +8,7 @@ import { db } from '../services/databaseService.js';
export const checkSetupStatus = async (req: Request, res: Response): Promise<void> => {
try {
const adminExists = await db.get<{ 'COUNT(*)': number }>(
'SELECT COUNT(*) FROM users WHERE role = ? AND is_active = 1',
'SELECT COUNT(*) FROM employees WHERE role = ? AND is_active = 1',
['admin']
);

View File

@@ -44,9 +44,9 @@ export const EMPLOYEE_TYPE_CONFIG = {
} as const;
export const ROLE_CONFIG = [
{ value: 'user', label: 'Mitarbeiter', description: 'Kann eigene Schichten einsehen', color: '#27ae60' },
{ value: 'instandhalter', label: 'Instandhalter', description: 'Kann Schichtpläne erstellen und Mitarbeiter verwalten', color: '#3498db' },
{ value: 'admin', label: 'Administrator', description: 'Voller Zugriff auf alle Funktionen', color: '#e74c3c' }
{ value: 'user' as const, label: 'Mitarbeiter', description: 'Kann eigene Schichten einsehen', color: '#27ae60' },
{ value: 'maintenance' as const, label: 'Instandhalter', description: 'Kann Schichtpläne erstellen und Mitarbeiter verwalten', color: '#3498db' },
{ value: 'admin' as const, label: 'Administrator', description: 'Voller Zugriff auf alle Funktionen', color: '#e74c3c' }
] as const;
// Contract type descriptions

View File

@@ -3,7 +3,6 @@ import { db } from '../services/databaseService.js';
async function checkTemplates() {
try {
// KORREKTUR: employees statt users verwenden
const templates = await db.all<any>(
`SELECT sp.*, e.name as created_by_name
FROM shift_plans sp

View File

@@ -18,7 +18,7 @@ export async function initializeDatabase(): Promise<void> {
// Check if users table exists and has data
try {
const existingAdmin = await db.get<{ count: number }>(
"SELECT COUNT(*) as count FROM users WHERE role = 'admin'"
"SELECT COUNT(*) as count FROM employees WHERE role = 'admin'"
);
if (existingAdmin && existingAdmin.count > 0) {
@@ -43,12 +43,14 @@ export async function initializeDatabase(): Promise<void> {
// Drop existing tables in reverse order of dependencies if they exist
const tablesToDrop = [
'employee_availabilities',
'assigned_shifts',
'shift_plans',
'template_shifts',
'shift_templates',
'users'
'employees',
'time_slots',
'shifts',
'scheduled_shifts',
'shift_assignments',
'employee_availability',
'applied_migrations',
'shift_plans'
];
for (const table of tablesToDrop) {

View File

@@ -40,7 +40,7 @@ app.get('/api/initial-setup', async (req: any, res: any) => {
const { db } = await import('./services/databaseService.js');
const adminExists = await db.get<{ 'COUNT(*)': number }>(
'SELECT COUNT(*) FROM users WHERE role = ?',
'SELECT COUNT(*) FROM employees WHERE role = ?',
['admin']
);