CREATE TABLE oauth_accounts ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, provider VARCHAR(50) NOT NULL, provider_account_id VARCHAR(255) NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), UNIQUE(provider, provider_account_id) ); CREATE INDEX idx_oauth_accounts_user_id ON oauth_accounts(user_id); CREATE TABLE subscriptions ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, stripe_customer_id VARCHAR(255), stripe_subscription_id VARCHAR(255), stripe_price_id VARCHAR(255), status VARCHAR(50) NOT NULL DEFAULT 'incomplete', tier VARCHAR(50) NOT NULL DEFAULT 'free', current_period_start TIMESTAMPTZ, current_period_end TIMESTAMPTZ, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() ); CREATE INDEX idx_subscriptions_user_id ON subscriptions(user_id); CREATE INDEX idx_subscriptions_stripe_customer ON subscriptions(stripe_customer_id);