Files
lunarfront-app/packages/backend/src/db/migrations/0043_user-pin.sql
ryan ac9b615470
Some checks failed
Build & Release / build (push) Failing after 1m53s
fix: renumber migrations 0042-0045 after rebase onto main
Main added 0041_app_settings, so branch migrations shift up by one.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 16:06:12 +00:00

21 lines
925 B
SQL

ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "pin_hash" varchar(255);
ALTER TABLE "user" ADD COLUMN IF NOT EXISTS "employee_number" varchar(20) UNIQUE;
-- Auto-assign employee numbers to existing users
DO $$ DECLARE r RECORD; num INT := 1001;
BEGIN
FOR r IN (SELECT id FROM "user" WHERE employee_number IS NULL ORDER BY created_at) LOOP
UPDATE "user" SET employee_number = num::text WHERE id = r.id;
num := num + 1;
END LOOP;
END $$;
-- Seed POS config
INSERT INTO "app_config" ("key", "value", "description") VALUES
('pos_lock_timeout', '15', 'POS auto-lock timeout in minutes (0 to disable)'),
('receipt_header', '', 'Text shown below logo on receipts'),
('receipt_footer', '', 'Thank you message at bottom of receipt'),
('receipt_return_policy', '', 'Return policy text on receipt (blank to hide)'),
('receipt_social', '', 'Website or social media shown on receipt')
ON CONFLICT ("key") DO NOTHING;