feat: Add kiosk setup and API testing scripts, alongside database function fixes for API key generation and short IDs.

This commit is contained in:
Marco Gallegos
2026-01-16 16:23:43 -06:00
parent cf2d8f9b4d
commit 9bb0caaecf
11 changed files with 1099 additions and 0 deletions

26
scripts/fix-short-id.sql Normal file
View File

@@ -0,0 +1,26 @@
-- Fix short_id variable name collision
CREATE OR REPLACE FUNCTION generate_short_id()
RETURNS VARCHAR(6) AS $$
DECLARE
chars VARCHAR(36) := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
v_short_id VARCHAR(6);
attempts INT := 0;
max_attempts INT := 10;
BEGIN
LOOP
v_short_id := '';
FOR i IN 1..6 LOOP
v_short_id := v_short_id || substr(chars, floor(random() * 36 + 1)::INT, 1);
END LOOP;
IF NOT EXISTS (SELECT 1 FROM bookings WHERE short_id = v_short_id) THEN
RETURN v_short_id;
END IF;
attempts := attempts + 1;
IF attempts >= max_attempts THEN
RAISE EXCEPTION 'Failed to generate unique short_id after % attempts', max_attempts;
END IF;
END LOOP;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;