Batch Keys Gefixt
Dieser Commit ist enthalten in:
26
JOURNAL.md
26
JOURNAL.md
@@ -1095,3 +1095,29 @@ Die Session-Daten werden erst gefüllt, wenn der License Server API implementier
|
|||||||
- ✅ Frontend zeigt berechnetes Datum sofort an
|
- ✅ Frontend zeigt berechnetes Datum sofort an
|
||||||
- ✅ Backend validiert die Berechnung
|
- ✅ Backend validiert die Berechnung
|
||||||
- ✅ Standardwert (1 Jahr) voreingestellt
|
- ✅ Standardwert (1 Jahr) voreingestellt
|
||||||
|
|
||||||
|
## 2025-01-06: Bugfix - created_at für licenses Tabelle
|
||||||
|
|
||||||
|
**Problem:**
|
||||||
|
- Batch-Generierung schlug fehl mit "Fehler bei der Batch-Generierung!"
|
||||||
|
- INSERT Statement versuchte `created_at` zu setzen, aber Spalte existierte nicht
|
||||||
|
- Inkonsistenz: Einzellizenzen hatten kein created_at, Batch-Lizenzen versuchten es zu setzen
|
||||||
|
|
||||||
|
**Lösung:**
|
||||||
|
1. **Datenbank-Schema erweitert:**
|
||||||
|
- `created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP` zur licenses Tabelle hinzugefügt
|
||||||
|
- Migration für bestehende Datenbanken implementiert
|
||||||
|
- Konsistent mit customers Tabelle
|
||||||
|
2. **Code bereinigt:**
|
||||||
|
- Explizites `created_at` aus Batch-INSERT entfernt
|
||||||
|
- Datenbank setzt nun automatisch den Zeitstempel bei ALLEN Lizenzen
|
||||||
|
|
||||||
|
**Änderungen:**
|
||||||
|
- `init.sql`: created_at Spalte zur licenses Tabelle mit DEFAULT-Wert
|
||||||
|
- `init.sql`: Migration für bestehende Datenbanken
|
||||||
|
- `app.py`: Entfernt explizites created_at aus batch_licenses()
|
||||||
|
|
||||||
|
**Status:**
|
||||||
|
- ✅ Alle Lizenzen haben nun automatisch einen Erstellungszeitstempel
|
||||||
|
- ✅ Batch-Generierung funktioniert wieder
|
||||||
|
- ✅ Konsistente Zeitstempel für Audit-Zwecke
|
||||||
@@ -1213,8 +1213,8 @@ def batch_licenses():
|
|||||||
# Lizenz einfügen
|
# Lizenz einfügen
|
||||||
cur.execute("""
|
cur.execute("""
|
||||||
INSERT INTO licenses (license_key, customer_id, license_type,
|
INSERT INTO licenses (license_key, customer_id, license_type,
|
||||||
valid_from, valid_until, is_active, created_at)
|
valid_from, valid_until, is_active)
|
||||||
VALUES (%s, %s, %s, %s, %s, true, NOW())
|
VALUES (%s, %s, %s, %s, %s, true)
|
||||||
RETURNING id
|
RETURNING id
|
||||||
""", (license_key, customer_id, license_type, valid_from, valid_until))
|
""", (license_key, customer_id, license_type, valid_from, valid_until))
|
||||||
license_id = cur.fetchone()[0]
|
license_id = cur.fetchone()[0]
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ CREATE TABLE IF NOT EXISTS licenses (
|
|||||||
license_type TEXT NOT NULL,
|
license_type TEXT NOT NULL,
|
||||||
valid_from DATE NOT NULL,
|
valid_from DATE NOT NULL,
|
||||||
valid_until DATE NOT NULL,
|
valid_until DATE NOT NULL,
|
||||||
is_active BOOLEAN DEFAULT TRUE
|
is_active BOOLEAN DEFAULT TRUE,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS sessions (
|
CREATE TABLE IF NOT EXISTS sessions (
|
||||||
@@ -86,3 +87,15 @@ CREATE TABLE IF NOT EXISTS login_attempts (
|
|||||||
-- Index für schnelle Abfragen
|
-- Index für schnelle Abfragen
|
||||||
CREATE INDEX idx_login_attempts_blocked_until ON login_attempts(blocked_until);
|
CREATE INDEX idx_login_attempts_blocked_until ON login_attempts(blocked_until);
|
||||||
CREATE INDEX idx_login_attempts_last_attempt ON login_attempts(last_attempt DESC);
|
CREATE INDEX idx_login_attempts_last_attempt ON login_attempts(last_attempt DESC);
|
||||||
|
|
||||||
|
-- Migration: Füge created_at zu licenses hinzu, falls noch nicht vorhanden
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
|
||||||
|
WHERE table_name = 'licenses' AND column_name = 'created_at') THEN
|
||||||
|
ALTER TABLE licenses ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
|
||||||
|
-- Setze created_at für bestehende Einträge auf das valid_from Datum
|
||||||
|
UPDATE licenses SET created_at = valid_from WHERE created_at IS NULL;
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren