Update README with MQTT tables and parent_user_id documentation
Added documentation for: - parent_user_id column in User table (hierarchical user management) - mqtt_credentials table with device authentication - mqtt_acl_rules table for topic permissions - mqtt_sync_status table for broker synchronization - All new database indexes - Updated ER diagram with new relationships 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
66
README.md
66
README.md
@@ -158,6 +158,7 @@ username TEXT UNIQUE NOT NULL
|
|||||||
email TEXT
|
email TEXT
|
||||||
passwordHash TEXT NOT NULL
|
passwordHash TEXT NOT NULL
|
||||||
role TEXT NOT NULL DEFAULT 'VIEWER' -- ADMIN oder VIEWER
|
role TEXT NOT NULL DEFAULT 'VIEWER' -- ADMIN oder VIEWER
|
||||||
|
parent_user_id TEXT -- FK zu User.id (Hierarchie)
|
||||||
createdAt TEXT DEFAULT (datetime('now'))
|
createdAt TEXT DEFAULT (datetime('now'))
|
||||||
updatedAt TEXT DEFAULT (datetime('now'))
|
updatedAt TEXT DEFAULT (datetime('now'))
|
||||||
lastLoginAt TEXT
|
lastLoginAt TEXT
|
||||||
@@ -176,10 +177,44 @@ createdAt TEXT DEFAULT (datetime('now'))
|
|||||||
updatedAt TEXT DEFAULT (datetime('now'))
|
updatedAt TEXT DEFAULT (datetime('now'))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**MQTT Credentials Tabelle:**
|
||||||
|
```sql
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||||
|
device_id TEXT NOT NULL UNIQUE -- FK zu Device.id
|
||||||
|
mqtt_username TEXT NOT NULL UNIQUE
|
||||||
|
mqtt_password_hash TEXT NOT NULL
|
||||||
|
enabled INTEGER DEFAULT 1 -- 0 oder 1
|
||||||
|
created_at TEXT DEFAULT (datetime('now'))
|
||||||
|
updated_at TEXT DEFAULT (datetime('now'))
|
||||||
|
```
|
||||||
|
|
||||||
|
**MQTT ACL Rules Tabelle:**
|
||||||
|
```sql
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||||
|
device_id TEXT NOT NULL -- FK zu Device.id
|
||||||
|
topic_pattern TEXT NOT NULL
|
||||||
|
permission TEXT NOT NULL -- 'read', 'write', 'readwrite'
|
||||||
|
created_at TEXT DEFAULT (datetime('now'))
|
||||||
|
```
|
||||||
|
|
||||||
|
**MQTT Sync Status Tabelle:**
|
||||||
|
```sql
|
||||||
|
id INTEGER PRIMARY KEY CHECK (id = 1) -- Singleton
|
||||||
|
pending_changes INTEGER DEFAULT 0
|
||||||
|
last_sync_at TEXT
|
||||||
|
last_sync_status TEXT
|
||||||
|
created_at TEXT DEFAULT (datetime('now'))
|
||||||
|
updated_at TEXT DEFAULT (datetime('now'))
|
||||||
|
```
|
||||||
|
|
||||||
**Indexes:**
|
**Indexes:**
|
||||||
- `idx_user_username` ON User(username)
|
- `idx_user_username` ON User(username)
|
||||||
|
- `idx_user_parent` ON User(parent_user_id)
|
||||||
- `idx_device_owner` ON Device(ownerId)
|
- `idx_device_owner` ON Device(ownerId)
|
||||||
- `idx_device_active` ON Device(isActive)
|
- `idx_device_active` ON Device(isActive)
|
||||||
|
- `idx_mqtt_credentials_device` ON mqtt_credentials(device_id)
|
||||||
|
- `idx_mqtt_credentials_username` ON mqtt_credentials(mqtt_username)
|
||||||
|
- `idx_mqtt_acl_device` ON mqtt_acl_rules(device_id)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -360,8 +395,11 @@ graph LR
|
|||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
erDiagram
|
erDiagram
|
||||||
|
USER ||--o{ USER : "parent_user_id"
|
||||||
USER ||--o{ DEVICE : owns
|
USER ||--o{ DEVICE : owns
|
||||||
DEVICE ||--o{ LOCATION : tracks
|
DEVICE ||--o{ LOCATION : tracks
|
||||||
|
DEVICE ||--o| MQTT_CREDENTIALS : has
|
||||||
|
DEVICE ||--o{ MQTT_ACL_RULES : has
|
||||||
|
|
||||||
USER {
|
USER {
|
||||||
string id PK
|
string id PK
|
||||||
@@ -369,6 +407,7 @@ erDiagram
|
|||||||
string email
|
string email
|
||||||
string passwordHash
|
string passwordHash
|
||||||
string role
|
string role
|
||||||
|
string parent_user_id FK
|
||||||
datetime createdAt
|
datetime createdAt
|
||||||
datetime lastLoginAt
|
datetime lastLoginAt
|
||||||
}
|
}
|
||||||
@@ -383,6 +422,33 @@ erDiagram
|
|||||||
datetime createdAt
|
datetime createdAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MQTT_CREDENTIALS {
|
||||||
|
int id PK
|
||||||
|
string device_id FK_UK
|
||||||
|
string mqtt_username UK
|
||||||
|
string mqtt_password_hash
|
||||||
|
boolean enabled
|
||||||
|
datetime created_at
|
||||||
|
datetime updated_at
|
||||||
|
}
|
||||||
|
|
||||||
|
MQTT_ACL_RULES {
|
||||||
|
int id PK
|
||||||
|
string device_id FK
|
||||||
|
string topic_pattern
|
||||||
|
string permission
|
||||||
|
datetime created_at
|
||||||
|
}
|
||||||
|
|
||||||
|
MQTT_SYNC_STATUS {
|
||||||
|
int id PK
|
||||||
|
int pending_changes
|
||||||
|
datetime last_sync_at
|
||||||
|
string last_sync_status
|
||||||
|
datetime created_at
|
||||||
|
datetime updated_at
|
||||||
|
}
|
||||||
|
|
||||||
LOCATION {
|
LOCATION {
|
||||||
int id PK
|
int id PK
|
||||||
float latitude
|
float latitude
|
||||||
|
|||||||
Reference in New Issue
Block a user