Self Order

This commit is contained in:
2026-05-04 16:23:29 +07:00
parent 2c76962959
commit b993da898f
16 changed files with 443 additions and 3 deletions
@@ -0,0 +1,7 @@
-- Remove source column from orders
ALTER TABLE orders DROP COLUMN IF EXISTS source;
-- Remove token column from tables
DROP INDEX IF EXISTS idx_tables_token_active;
DROP INDEX IF EXISTS idx_tables_token;
ALTER TABLE tables DROP COLUMN IF EXISTS token;
@@ -0,0 +1,13 @@
-- Add token column to tables for self-order QR code identification
ALTER TABLE tables ADD COLUMN IF NOT EXISTS token VARCHAR(100);
CREATE UNIQUE INDEX IF NOT EXISTS idx_tables_token ON tables(token);
CREATE INDEX IF NOT EXISTS idx_tables_token_active ON tables(token) WHERE is_active = true;
-- Backfill existing tables with unique tokens
-- Uses gen_random_uuid() to generate unique tokens for each existing table
UPDATE tables SET token = gen_random_uuid()::text WHERE token IS NULL;
-- Make token NOT NULL after backfill (optional, keep nullable for flexibility)
-- Add source column to orders for tracking order origin
ALTER TABLE orders ADD COLUMN IF NOT EXISTS source VARCHAR(50) DEFAULT 'staff';