DO $$ 
    BEGIN
          IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
        BEGIN
           CREATE TABLE public."EventExceptions" (
    "Id" bigserial PRIMARY KEY,
    "StartDate" timestamp NOT NULL, 
    "EndDate" timestamp NOT NULL,
    "Date" timestamp without time zone NOT NULL,
    "OwnerId" bigint NOT NULL,
    "DetailId" bigint NULL,
    "ToRecurringId" bigint NULL,
    "FromRecurringId" bigint NOT NULL,
    "Status" integer NOT NULL,
    "Count" integer NULL,
    "LastModificationDate" timestamp without time zone DEFAULT timezone('utc', now())  NOT NULL
);
        EXCEPTION
            WHEN duplicate_table THEN RAISE NOTICE 'Create table <EventExceptions>.';
        END;
    END;
$$


