fix: add missing qr_scans table creation to fix 500 error on /api/qr

This commit is contained in:
Mohan Ki
2026-07-27 16:38:23 +05:30
parent 8c17fac692
commit 386071f48d
2 changed files with 26 additions and 0 deletions
+13
View File
@@ -113,6 +113,19 @@ app.get('/health', healthCheck);
// Auto-migrate schema
pgPool.query(`ALTER TABLE qr_codes ADD COLUMN IF NOT EXISTS name VARCHAR(255);`).catch(console.error);
pgPool.query(`
CREATE TABLE IF NOT EXISTS qr_scans (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
qr_code_id UUID REFERENCES qr_codes(id) ON DELETE CASCADE,
ip_address VARCHAR(45),
user_agent TEXT,
os VARCHAR(50),
device_type VARCHAR(50),
browser VARCHAR(50),
country VARCHAR(100),
city VARCHAR(100),
scanned_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);`).catch(console.error);
app.listen(port, () => {
console.log(`CK-QR API listening on port ${port}`);