AlTER TABLE account DROP column email;

DO $$
    BEGIN
        IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'leadtargettype') THEN
            CREATE TYPE LeadTargetType AS ENUM ('mail', 'telegram', 'whatsapp');
        END IF;
    END $$;

CREATE TABLE IF NOT EXISTS leadtarget(
    ID BIGSERIAL UNIQUE NOT NULL PRIMARY KEY,
    AccountID varchar(30) NOT NULL,
    Type LeadTargetType NOT NULL,
    QuizID integer NOT NULL DEFAULT 0,
    Target text NOT NULL,
    InviteLink text NOT NULL DEFAULT '',
    Deleted boolean NOT NULL DEFAULT false,
    CreatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
