gitdataai/libs/migrate/sql/m20260509_000001_create_user_billing.sql

14 lines
533 B
SQL

CREATE TABLE user_billing (
user_uuid UUID PRIMARY KEY,
balance DECIMAL(20, 4) DEFAULT 10.0000 NOT NULL,
currency VARCHAR(10) DEFAULT 'USD' NOT NULL,
is_pro BOOLEAN DEFAULT FALSE NOT NULL,
monthly_quota DECIMAL(20, 4) DEFAULT 0 NOT NULL,
month_used DECIMAL(20, 4) DEFAULT 0 NOT NULL,
cycle_start TIMESTAMPTZ,
cycle_end TIMESTAMPTZ,
updated_at TIMESTAMPTZ DEFAULT NOW(),
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX idx_user_billing_is_pro ON user_billing (is_pro) WHERE is_pro = TRUE;