-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sql
More file actions
56 lines (50 loc) · 1.71 KB
/
install.sql
File metadata and controls
56 lines (50 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
-- Erstelle Datenbank
CREATE DATABASE IF NOT EXISTS divera_stein_sync
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
USE divera_stein_sync;
-- Tabelle für Synchronisations-Log
CREATE TABLE IF NOT EXISTS sync_log (
id INT AUTO_INCREMENT PRIMARY KEY,
vehicle_name VARCHAR(100) NOT NULL,
divera_id INT,
stein_id INT,
sync_direction VARCHAR(50),
fields_synced JSON,
success BOOLEAN DEFAULT FALSE,
error_message TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_created (created_at),
INDEX idx_vehicle (vehicle_name),
INDEX idx_success (success)
) ENGINE=InnoDB;
-- Tabelle für Feld-Konfiguration
CREATE TABLE IF NOT EXISTS sync_config (
id INT AUTO_INCREMENT PRIMARY KEY,
field_name VARCHAR(50) UNIQUE NOT NULL,
active BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;
-- Standard-Felder einfügen
INSERT INTO sync_config (field_name, active) VALUES
('status', 1),
('comment', 1),
('position', 0),
('crew', 0)
ON DUPLICATE KEY UPDATE field_name=field_name;
-- Tabelle für System-Status
CREATE TABLE IF NOT EXISTS system_status (
id INT AUTO_INCREMENT PRIMARY KEY,
last_sync TIMESTAMP NULL,
last_sync_count INT DEFAULT 0,
total_syncs INT DEFAULT 0,
auto_sync_enabled BOOLEAN DEFAULT FALSE,
sync_interval INT DEFAULT 300,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB;
-- Initial System Status
INSERT INTO system_status (auto_sync_enabled, sync_interval)
VALUES (0, 300)
ON DUPLICATE KEY UPDATE id=id;