mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 01:47:47 +08:00
Add dashboard and overview analytics, health monitoring, provider expense tracking, and announcement updates across the gateway and frontend. Keep schema migrations free of historical backfills while preserving automatic backfill execution. Bound migration deadlines, run schema preparation before Compose replacement, and anonymize deleted dashboard users. Include the current documentation cleanup and regression coverage.
26 lines
1.1 KiB
SQL
26 lines
1.1 KiB
SQL
-- Manual purchasing ledger; no foreign-key cascade may erase historical expenditures.
|
|
CREATE TABLE IF NOT EXISTS public.provider_expenses (
|
|
id text PRIMARY KEY,
|
|
client_request_id text NOT NULL UNIQUE,
|
|
provider_id text NOT NULL,
|
|
provider_name text NOT NULL,
|
|
kind text NOT NULL CHECK (kind IN ('recharge', 'subscription', 'other')),
|
|
amount numeric(20,8) NOT NULL CHECK (amount > 0),
|
|
currency text NOT NULL CHECK (currency ~ '^[A-Z]{3}$'),
|
|
paid_at timestamptz NOT NULL,
|
|
period_start timestamptz,
|
|
period_end timestamptz,
|
|
note text,
|
|
external_reference text,
|
|
created_by text,
|
|
created_at timestamptz NOT NULL DEFAULT NOW(),
|
|
voided_at timestamptz,
|
|
voided_by text,
|
|
CONSTRAINT provider_expenses_period_check CHECK (
|
|
(period_start IS NULL AND period_end IS NULL) OR
|
|
(period_start IS NOT NULL AND period_end IS NOT NULL AND period_start < period_end)
|
|
)
|
|
);
|
|
CREATE INDEX IF NOT EXISTS ix_provider_expenses_paid_at ON public.provider_expenses(paid_at, id);
|
|
CREATE INDEX IF NOT EXISTS ix_provider_expenses_provider_paid_at ON public.provider_expenses(provider_id, paid_at);
|