feat: Add comprehensive test data generator and enhance user management with initials

This commit is contained in:
2026-01-26 23:18:49 +01:00
parent cb815177a1
commit c13a991778
3 changed files with 879 additions and 3 deletions

View File

@@ -397,6 +397,34 @@ export default function initializeDatabase() {
console.warn("Migration warning:", e.message);
}
// Migration: Add initial column to users table
try {
const columns = db.prepare("PRAGMA table_info(users)").all();
const hasInitial = columns.some(col => col.name === 'initial');
if (!hasInitial) {
// Add initial column
db.exec(`ALTER TABLE users ADD COLUMN initial TEXT;`);
// Generate initials from existing names
const users = db.prepare('SELECT id, name FROM users WHERE initial IS NULL').all();
const updateStmt = db.prepare('UPDATE users SET initial = ? WHERE id = ?');
users.forEach(user => {
if (user.name) {
// Generate initials from name (e.g., "John Doe" -> "JD")
const nameParts = user.name.trim().split(/\s+/);
const initial = nameParts.map(part => part.charAt(0).toUpperCase()).join('');
updateStmt.run(initial, user.id);
}
});
console.log("✅ Added initial column to users table and generated initials");
}
} catch (e) {
console.warn("Migration warning:", e.message);
}
// Migration: Rename project_type to task_category in task_sets
try {
// Check if the old column exists and rename it