16 lines
806 B
MySQL
16 lines
806 B
MySQL
|
|
-- Reviews: customers leave reviews on professionals after an accepted lead
|
||
|
|
CREATE TABLE IF NOT EXISTS reviews (
|
||
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||
|
|
lead_request_id UUID NOT NULL REFERENCES lead_requests(id) ON DELETE CASCADE UNIQUE,
|
||
|
|
customer_id UUID NOT NULL REFERENCES customers(id) ON DELETE CASCADE,
|
||
|
|
professional_id UUID NOT NULL REFERENCES professionals(id) ON DELETE CASCADE,
|
||
|
|
rating SMALLINT NOT NULL CHECK (rating >= 1 AND rating <= 5),
|
||
|
|
comment TEXT,
|
||
|
|
is_published BOOLEAN NOT NULL DEFAULT true,
|
||
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||
|
|
);
|
||
|
|
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_reviews_professional_id ON reviews(professional_id);
|
||
|
|
CREATE INDEX IF NOT EXISTS idx_reviews_customer_id ON reviews(customer_id);
|