we went to mocks - now going to unit-setup.ts - centralized
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 37m52s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 37m52s
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
-- MASTER SCHEMA SCRIPT
|
||||
-- ============================================================================
|
||||
-- Purpose:
|
||||
-- This file contains the master SQL schema for the entire Supabase database.
|
||||
-- This file contains the master SQL schema for the entire Postgres database.
|
||||
-- It is designed to be a "one-click" script that can be run in a PostgreSQL
|
||||
-- database to set up the entire backend from scratch, including:
|
||||
-- 1. Enabling required Postgres extensions.
|
||||
@@ -19,7 +19,7 @@
|
||||
-- ============================================================================
|
||||
-- PART 2: TABLES
|
||||
-- ============================================================================
|
||||
-- 1. Users - This replaces the Supabase `auth.users` table.
|
||||
-- 1. Users table for authentication.
|
||||
CREATE TABLE IF NOT EXISTS public.users (
|
||||
user_id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
email TEXT NOT NULL UNIQUE,
|
||||
@@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS public.users (
|
||||
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 TABLE public.users IS 'Stores user authentication information.';
|
||||
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.';
|
||||
@@ -107,7 +107,7 @@ CREATE INDEX IF NOT EXISTS idx_flyers_store_id ON public.flyers(store_id);
|
||||
-- This is particularly useful for the recalculate_price_history_on_flyer_item_delete trigger.
|
||||
CREATE INDEX IF NOT EXISTS idx_flyers_valid_dates_store ON public.flyers(valid_from, valid_to, store_id);
|
||||
COMMENT ON COLUMN public.flyers.file_name IS 'The original name of the uploaded flyer file (e.g., "flyer_week_1.pdf").';
|
||||
COMMENT ON COLUMN public.flyers.image_url IS 'The public URL of the primary flyer image stored in Supabase Storage.';
|
||||
COMMENT ON COLUMN public.flyers.image_url IS 'The public URL of the primary flyer image stored on server Storage.';
|
||||
COMMENT ON COLUMN public.flyers.checksum IS 'A SHA-256 hash of the original file content to prevent duplicate processing.';
|
||||
COMMENT ON COLUMN public.flyers.store_id IS 'Foreign key linking this flyer to a specific store in the `stores` table.';
|
||||
COMMENT ON COLUMN public.flyers.valid_from IS 'The start date of the sale period for this flyer, extracted by the AI.';
|
||||
@@ -1066,26 +1066,8 @@ INSERT INTO public.dietary_restrictions (name, type) VALUES
|
||||
('Tree Nuts', 'allergy'), ('Peanuts', 'allergy'), ('Soy', 'allergy'), ('Wheat', 'allergy')
|
||||
ON CONFLICT (name) DO NOTHING;
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- PART 3: STORAGE
|
||||
-- ============================================================================
|
||||
-- The `storage.buckets` table is a Supabase-specific feature.
|
||||
-- This section is removed. You will need to implement your own file storage
|
||||
-- solution (e.g., local filesystem, S3-compatible service) and store
|
||||
-- URLs/paths in the `flyers.image_url` column.
|
||||
|
||||
-- ============================================================================
|
||||
-- PART 4: ROW LEVEL SECURITY (RLS)
|
||||
-- ============================================================================
|
||||
-- Row Level Security (RLS) policies are removed as they rely on Supabase-specific
|
||||
-- functions like `auth.uid()`. In a self-hosted environment, authorization
|
||||
-- should be handled at the application layer (e.g., your backend API ensures
|
||||
-- a user can only query their own data).
|
||||
|
||||
-- ============================================================================
|
||||
-- PART 5: DATABASE FUNCTIONS
|
||||
-- PART 3: DATABASE FUNCTIONS
|
||||
-- ============================================================================
|
||||
-- Function to find the best current sale price for a user's watched items.
|
||||
-- This function queries all currently active flyers to find the lowest price
|
||||
@@ -2007,11 +1989,8 @@ AS $$
|
||||
$$;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- PART 7: TRIGGERS
|
||||
-- PART 4: TRIGGERS
|
||||
-- ============================================================================
|
||||
|
||||
-- 1. Set up the trigger to automatically create a profile when a new user signs up.
|
||||
|
||||
Reference in New Issue
Block a user