CREATE TABLE plans (
    id                BIGSERIAL PRIMARY KEY,
    plan_code         VARCHAR(50) NOT NULL,
    name              VARCHAR(100) NOT NULL,
    quota_policy_json JSONB NOT NULL DEFAULT '{}',
    status            VARCHAR(20) NOT NULL DEFAULT 'active',
    created_at        TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at        TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    deleted_at        TIMESTAMPTZ
);
CREATE UNIQUE INDEX uk_plan_code_active ON plans(plan_code) WHERE deleted_at IS NULL;
