const { sequelize, connectDB } = require('./config/database'); const Block = require('./models/Block'); const User = require('./models/User'); const eventBlocks = [ { name: 'Stuhl (Standard)', category: 'Bestuhlung', is_public: true, svg_data: ` ` }, { name: 'Tisch (Rechteck 180x80)', category: 'Möbel', is_public: true, svg_data: ` ` }, { name: 'Tisch (Rund Ø120)', category: 'Möbel', is_public: true, svg_data: ` ` }, { name: 'Bühne (Modular 200x100)', category: 'Bühne', is_public: true, svg_data: ` ` }, { name: 'Stehtisch', category: 'Möbel', is_public: true, svg_data: ` ` }, { name: 'Barhocker', category: 'Bestuhlung', is_public: true, svg_data: ` ` }, { name: 'Mischpult', category: 'Technik', is_public: true, svg_data: ` ` }, { name: 'Lautsprecher', category: 'Technik', is_public: true, svg_data: ` ` }, { name: 'Trennwand', category: 'Raum', is_public: true, svg_data: ` ` }, { name: 'Notausgang-Schild', category: 'Sicherheit', is_public: true, svg_data: ` EXIT ` }, ]; async function seed() { try { await connectDB(); // Create admin user if not exists const existingUser = await User.findOne({ where: { email: 'admin@cad.local' } }); if (!existingUser) { await User.create({ email: 'admin@cad.local', password: 'admin123' }); console.log('Admin user created: admin@cad.local / admin123'); } // Clear existing blocks await Block.destroy({ where: {} }); console.log('Existing blocks cleared.'); // Insert new blocks for (const block of eventBlocks) { await Block.create(block); } console.log(`${eventBlocks.length} blocks created successfully.`); process.exit(0); } catch (err) { console.error('Seed failed:', err); process.exit(1); } } seed();