more ts and break apart big ass files
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Has been cancelled

This commit is contained in:
2025-11-21 10:17:28 -08:00
parent 75f098a1f4
commit 18e475f75a
9 changed files with 330 additions and 67 deletions

View File

@@ -12,11 +12,15 @@ CREATE TABLE IF NOT EXISTS public.users (
email TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
refresh_token TEXT,
failed_login_attempts INTEGER DEFAULT 0,
last_failed_login TIMESTAMPTZ,
created_at TIMESTAMPTZ DEFAULT now() NOT NULL,
updated_at TIMESTAMPTZ DEFAULT now() NOT NULL
);
COMMENT ON TABLE public.users IS 'Stores user authentication information, replacing Supabase auth.';
COMMENT ON COLUMN public.users.refresh_token IS 'Stores the long-lived refresh token for re-authentication.';
COMMENT ON COLUMN public.users.failed_login_attempts IS 'Tracks the number of consecutive failed login attempts.';
COMMENT ON COLUMN public.users.last_failed_login IS 'Timestamp of the last failed login attempt.';
-- Add an index on the refresh_token for faster lookups when refreshing tokens.
CREATE INDEX IF NOT EXISTS idx_users_refresh_token ON public.users(refresh_token);
@@ -632,17 +636,18 @@ CREATE INDEX IF NOT EXISTS idx_favorite_stores_user_id ON public.favorite_stores
CREATE INDEX IF NOT EXISTS idx_favorite_stores_store_id ON public.favorite_stores(store_id);
-- 40. Log key user activities for analytics.
CREATE TABLE IF NOT EXISTS public.user_activity_log (
CREATE TABLE IF NOT EXISTS public.activity_log (
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
user_id UUID REFERENCES public.users(id) ON DELETE SET NULL,
activity_type TEXT NOT NULL,
entity_id TEXT,
action TEXT NOT NULL,
display_text TEXT NOT NULL,
icon TEXT,
details JSONB,
created_at TIMESTAMPTZ DEFAULT now() NOT NULL,
updated_at TIMESTAMPTZ DEFAULT now() NOT NULL
);
COMMENT ON TABLE public.user_activity_log IS 'Logs key user actions for analytics and behavior analysis.';
CREATE INDEX IF NOT EXISTS idx_user_activity_log_user_id ON public.user_activity_log(user_id);
COMMENT ON TABLE public.activity_log IS 'Logs key user and system actions for auditing and display in an activity feed.';
CREATE INDEX IF NOT EXISTS idx_activity_log_user_id ON public.activity_log(user_id);
-- 41. For users to group recipes into collections.
CREATE TABLE IF NOT EXISTS public.recipe_collections (