mirror of
https://github.com/Dvorinka/Bookra.git
synced 2026-10-28 07:41:16 +00:00
- Finish Paddle-to-Stripe billing migration; drop paddle/stripe libs - Renumber migrations; add 00012 memberships+manage_token, 00013 location_type_capacity - Add tests: admin, auth, bookings customer service - Remove graphify-out artifacts and stale env files Authored By: TDvorak <[email protected]> Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
46 lines
1.6 KiB
SQL
46 lines
1.6 KiB
SQL
-- +goose Up
|
|
CREATE TABLE IF NOT EXISTS tenant_sms_settings (
|
|
tenant_id uuid PRIMARY KEY REFERENCES tenants(id) ON DELETE CASCADE,
|
|
enabled boolean NOT NULL DEFAULT false,
|
|
sender_name text NOT NULL DEFAULT '',
|
|
monthly_limit integer,
|
|
stripe_subscription_item_id text,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS sms_usage_logs (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
recipient_phone text NOT NULL,
|
|
message_body text NOT NULL,
|
|
external_message_id text,
|
|
external_request_id text,
|
|
status text NOT NULL DEFAULT 'pending',
|
|
cost_cents integer NOT NULL DEFAULT 150,
|
|
sent_at timestamptz,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS sms_monthly_reports (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
year_month text NOT NULL,
|
|
message_count integer NOT NULL DEFAULT 0,
|
|
total_cost_cents integer NOT NULL DEFAULT 0,
|
|
stripe_invoice_id text,
|
|
invoice_sent_at timestamptz,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE (tenant_id, year_month)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_sms_usage_tenant_created ON sms_usage_logs (tenant_id, created_at DESC);
|
|
CREATE INDEX IF NOT EXISTS idx_sms_reports_tenant ON sms_monthly_reports (tenant_id, year_month DESC);
|
|
|
|
-- +goose Down
|
|
DROP INDEX IF EXISTS idx_sms_reports_tenant;
|
|
DROP INDEX IF EXISTS idx_sms_usage_tenant_created;
|
|
DROP TABLE IF EXISTS sms_monthly_reports;
|
|
DROP TABLE IF EXISTS sms_usage_logs;
|
|
DROP TABLE IF EXISTS tenant_sms_settings;
|