Neue Verwaltung der Gruppenzuordnung 1:n

This commit is contained in:
concierge committed 2026-10-30 09:02:46 +01:00
1 parent fa02a7ade0
commit 02c017d53d
34 files changed
+1306 -251

No files matched your search

+15 -1
View File
@@ -31,10 +31,22 @@ CREATE TABLE IF NOT EXISTS groups (
last_lat REAL,
last_lon REAL,
last_pos_at TIMESTAMP,
account_id INTEGER UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (tenant_id) REFERENCES tenants(id)
);
-- Zuordnung von Gruppen-Accounts zu Gruppen (1:n: eine Gruppe, viele Accounts).
-- Ein Account der Rolle "Gruppe" darf höchstens einer Gruppe zugeordnet sein.
CREATE TABLE IF NOT EXISTS group_accounts (
tenant_id INTEGER NOT NULL,
group_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (tenant_id, group_id, account_id),
UNIQUE (tenant_id, account_id),
FOREIGN KEY (tenant_id) REFERENCES tenants(id),
FOREIGN KEY (group_id) REFERENCES groups(id),
FOREIGN KEY (account_id) REFERENCES accounts(id)
);
@@ -145,6 +157,8 @@ CREATE TABLE IF NOT EXISTS transaction_log (
-- Indizes für Performance
CREATE INDEX IF NOT EXISTS idx_accounts_tenant ON accounts(tenant_id);
CREATE INDEX IF NOT EXISTS idx_groups_tenant ON groups(tenant_id);
CREATE INDEX IF NOT EXISTS idx_group_accounts_group
ON group_accounts(tenant_id, group_id);
CREATE INDEX IF NOT EXISTS idx_streets_tenant ON streets(tenant_id);
CREATE INDEX IF NOT EXISTS idx_street_house_numbers_lookup
ON street_house_numbers(tenant_id, street_name, house_number);