Files
kokken/scripts/add-featured-column.mjs
Alex Polo d9eb9cb314 Add advanced calendar features and toast notifications
Features:
- Toast notifications system (replaces alerts/confirms)
- Shift+click range selection for blocking dates
- Ctrl/Cmd+click for non-contiguous multi-date selection
- Progress indicators for all async operations
- Improved blocked dates list with formatted dates
- Red styling for blocked dates in calendar
- Blue styling for pending dates (Ctrl+click)
- Weekly schedule awareness (confirm before blocking work days)
- Non-working day styling (gray, dashed border)

Other improvements:
- Featured flag for menus (DB migration script included)
- Image handling fixes (renamed PNG files, updated references)
- Optimistic UI updates for better UX
- Multi-select bulk delete for blocked dates
- Show-only-blocked filter mode

Components:
- src/components/ui/toast.tsx (new)
- scripts/add-featured-column.mjs (new DB migration)
- scripts/README.md (migration documentation)
2025-10-31 20:06:41 +01:00

39 lines
1.3 KiB
JavaScript

import { pool } from '../src/lib/db.js';
// Idempotent migration using the project's DB pool: add `featured` TINYINT(1) to `menus` if missing
// Usage: node scripts/add-featured-column.mjs
async function columnExists(connection) {
const dbName = process.env.DB_NAME || 'warme';
const [rows] = await connection.query(
`SELECT COUNT(*) as cnt FROM information_schema.columns WHERE table_schema = ? AND table_name = 'menus' AND column_name = 'featured'`,
[dbName]
);
return rows[0].cnt > 0;
}
async function run() {
const connection = await pool.getConnection();
try {
const exists = await columnExists(connection);
if (exists) {
console.log('Column `featured` already exists on `menus`. Nothing to do.');
return;
}
console.log('Adding `featured` column to `menus`...');
await connection.query(`ALTER TABLE menus ADD COLUMN featured TINYINT(1) NOT NULL DEFAULT 0`);
console.log('Column added. Ensuring existing rows have 0...');
await connection.query(`UPDATE menus SET featured = 0 WHERE featured IS NULL`);
console.log('Migration completed successfully.');
} finally {
connection.release();
await pool.end();
}
}
run().then(() => process.exit(0)).catch((err) => {
console.error('Migration failed:', err);
process.exit(1);
});