19 lines
864 B
SQL
19 lines
864 B
SQL
-- 030: Insurance claims (compliance-service consumer protection)
|
|
|
|
CREATE TABLE IF NOT EXISTS insurance_claims (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id UUID NOT NULL REFERENCES users(id),
|
|
reason TEXT NOT NULL,
|
|
amount NUMERIC(18, 2) NOT NULL DEFAULT 0,
|
|
status VARCHAR(20) NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'processing', 'paid', 'rejected')),
|
|
related_order_id UUID,
|
|
processed_at TIMESTAMPTZ,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
version INT NOT NULL DEFAULT 1
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_insurance_claims_user_id ON insurance_claims(user_id);
|
|
CREATE INDEX IF NOT EXISTS idx_insurance_claims_status ON insurance_claims(status);
|
|
CREATE INDEX IF NOT EXISTS idx_insurance_claims_created_at ON insurance_claims(created_at DESC);
|