63 lines
2.3 KiB
SQL
63 lines
2.3 KiB
SQL
-- Migration: Room Bookings Table
|
|
|
|
-- Create room_bookings table
|
|
CREATE TABLE IF NOT EXISTS room_bookings (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
room_id INTEGER NOT NULL,
|
|
date TEXT NOT NULL,
|
|
time_from TEXT NOT NULL,
|
|
time_to TEXT NOT NULL,
|
|
guests INTEGER NOT NULL,
|
|
name TEXT NOT NULL,
|
|
phone TEXT,
|
|
email TEXT,
|
|
event_type TEXT,
|
|
notes TEXT,
|
|
status TEXT DEFAULT 'confirmed',
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (room_id) REFERENCES rooms(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Create indexes
|
|
CREATE INDEX IF NOT EXISTS idx_room_bookings_date ON room_bookings(date);
|
|
CREATE INDEX IF NOT EXISTS idx_room_bookings_room ON room_bookings(room_id);
|
|
CREATE INDEX IF NOT EXISTS idx_room_bookings_time ON room_bookings(time_from, time_to);
|
|
|
|
-- Insert test rooms
|
|
INSERT OR IGNORE INTO rooms (name, capacity, color) VALUES
|
|
('Hauptraum', 80, '#3b82f6'),
|
|
('Saal A', 40, '#10b981'),
|
|
('Saal B', 30, '#f59e0b');
|
|
|
|
-- Insert test tables for Hauptraum (room_id 1)
|
|
INSERT OR IGNORE INTO tables (room_id, x, y, width, height, max_guests, shape, status) VALUES
|
|
(1, 50, 50, 120, 80, 4, 'rect', 'active'),
|
|
(1, 200, 50, 120, 80, 4, 'rect', 'active'),
|
|
(1, 350, 50, 120, 80, 6, 'rect', 'active'),
|
|
(1, 50, 150, 100, 100, 6, 'round', 'active'),
|
|
(1, 200, 150, 120, 80, 4, 'rect', 'active'),
|
|
(1, 350, 150, 120, 80, 4, 'rect', 'active'),
|
|
(1, 50, 300, 150, 150, 8, 'round', 'active'),
|
|
(1, 250, 300, 150, 150, 10, 'round', 'active');
|
|
|
|
-- Insert test tables for Saal A (room_id 2)
|
|
INSERT OR IGNORE INTO tables (room_id, x, y, width, height, max_guests, shape, status) VALUES
|
|
(2, 50, 50, 100, 80, 4, 'rect', 'active'),
|
|
(2, 180, 50, 100, 80, 4, 'rect', 'active'),
|
|
(2, 310, 50, 100, 80, 4, 'rect', 'active'),
|
|
(2, 50, 150, 100, 80, 6, 'rect', 'active'),
|
|
(2, 180, 150, 100, 80, 6, 'rect', 'active');
|
|
|
|
-- Insert test tables for Saal B (room_id 3)
|
|
INSERT OR IGNORE INTO tables (room_id, x, y, width, height, max_guests, shape, status) VALUES
|
|
(3, 50, 50, 100, 80, 4, 'rect', 'active'),
|
|
(3, 180, 50, 100, 80, 4, 'rect', 'active'),
|
|
(3, 50, 150, 120, 80, 6, 'rect', 'active'),
|
|
(3, 200, 150, 80, 80, 4, 'round', 'active'),
|
|
(3, 320, 150, 80, 80, 4, 'round', 'active');
|
|
|
|
-- Verify
|
|
SELECT 'Migration complete' as status;
|
|
SELECT * FROM rooms;
|
|
SELECT COUNT(*) as table_count FROM tables;
|