v2.0: 3-Raum-System - Hauptraum, Saal A, Saal B mit 18 Tischen, Raum-Buchungen, API-Doku
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
-- Erstelle alle Tabellen zuerst
|
||||
CREATE TABLE IF NOT EXISTS rooms (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
capacity INTEGER NOT NULL DEFAULT 0,
|
||||
color TEXT DEFAULT '#3b82f6',
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tables (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
room_id INTEGER NOT NULL,
|
||||
x INTEGER DEFAULT 0,
|
||||
y INTEGER DEFAULT 0,
|
||||
width INTEGER DEFAULT 100,
|
||||
height INTEGER DEFAULT 100,
|
||||
max_guests INTEGER NOT NULL,
|
||||
shape TEXT DEFAULT 'rect',
|
||||
status TEXT DEFAULT 'active',
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (room_id) REFERENCES rooms(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
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 TABLE IF NOT EXISTS reservations (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
table_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,
|
||||
source TEXT DEFAULT 'manual',
|
||||
notes TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (table_id) REFERENCES tables(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_reservations_date ON reservations(date);
|
||||
CREATE INDEX IF NOT EXISTS idx_reservations_table ON reservations(table_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_tables_room ON tables(room_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_reservations_time ON reservations(time_from, time_to);
|
||||
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);
|
||||
|
||||
-- Raeume einfuegen
|
||||
INSERT INTO rooms (id, name, capacity, color) VALUES
|
||||
(1, 'Hauptraum', 80, '#3b82f6'),
|
||||
(2, 'Saal A', 40, '#10b981'),
|
||||
(3, 'Saal B', 30, '#f59e0b');
|
||||
|
||||
-- Tische fuer Hauptraum
|
||||
INSERT 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');
|
||||
|
||||
-- Tische fuer Saal A
|
||||
INSERT 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');
|
||||
|
||||
-- Tische fuer Saal B
|
||||
INSERT 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');
|
||||
|
||||
-- Test Daten
|
||||
INSERT INTO users (username, password, is_admin) VALUES
|
||||
('admin', '$2a$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 1);
|
||||
@@ -0,0 +1,62 @@
|
||||
-- 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;
|
||||
Reference in New Issue
Block a user