32 lines
1.4 KiB
MySQL
32 lines
1.4 KiB
MySQL
|
|
-- tax_rules backs apps/payments/src/admin.rs's admin tax-rule CRUD. Never
|
||
|
|
-- created by any active migration; init-db.sql has a differently-named
|
||
|
|
-- version (title/percentage/applicable_to) that doesn't match what the live
|
||
|
|
-- code reads/writes (name/tax_rate/applies_to) — schema below matches the
|
||
|
|
-- Rust code exactly.
|
||
|
|
CREATE TABLE IF NOT EXISTS tax_rules (
|
||
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||
|
|
name VARCHAR(255) NOT NULL,
|
||
|
|
tax_type VARCHAR(50) NOT NULL,
|
||
|
|
tax_rate NUMERIC(5,2) NOT NULL,
|
||
|
|
applies_to VARCHAR(50),
|
||
|
|
is_active BOOLEAN NOT NULL DEFAULT true,
|
||
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||
|
|
);
|
||
|
|
|
||
|
|
-- reviews backs apps/users/src/handlers/reviews.rs (professional review/
|
||
|
|
-- rating system, sourced from completed lead_requests). Same story — only
|
||
|
|
-- ever existed in scripts/init-db.sql, never applied.
|
||
|
|
CREATE TABLE IF NOT EXISTS reviews (
|
||
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||
|
|
lead_request_id UUID REFERENCES lead_requests(id) ON DELETE SET NULL,
|
||
|
|
customer_id UUID,
|
||
|
|
professional_id UUID,
|
||
|
|
rating SMALLINT NOT NULL,
|
||
|
|
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);
|