--up
-- Create enum type of feedback (users select this when manually cancelling)
CREATE TYPE stripe_cancellation_feedback AS ENUM ('customer_service', 'low_quality', 'missing_features', 'other', 'switched_service', 'too_complex', 'too_expensive', 'unused');

-- Create enum type of reason (why this subscription was canceled)
CREATE TYPE stripe_cancellation_reason AS ENUM ('cancellation_requested', 'payment_disputed', 'payment_failed');

CREATE TABLE subscription_cancellation_details (
    id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    user_id integer REFERENCES users (id) ON UPDATE RESTRICT ON DELETE CASCADE NOT NULL,
    reason stripe_cancellation_reason,
    feedback stripe_cancellation_feedback,
    comment text
);

--down
DROP TABLE subscription_cancellation_details;

DROP TYPE stripe_cancellation_feedback;
DROP TYPE stripe_cancellation_reason;
