DO $$ 
    BEGIN
  IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
 

        BEGIN
DROP TABLE public."PaymentsHistory";
CREATE TABLE public."PaymentsHistory" (
	"Id" BIGSERIAL NOT NULL PRIMARY KEY,
	"TariffId" BIGINT NOT NULL,
	"TenantId" BIGINT NOT NULL,
	"QuotaId" BIGINT NOT NULL,
	"Amount" FLOAT NOT NULL,
	"StartDate" timestamp without time zone NULL,
	"FinishDate" timestamp without time zone NULL,
        "IsActive" INT DEFAULT 1 NOT NULL,   
	"Timestamp" timestamp without time zone DEFAULT timezone('utc', now())  NOT NULL
);
 

        EXCEPTION
            WHEN OTHERS THEN RAISE NOTICE 'DROP AND CREATE <PaymentsHistory> error.';
        END;
    END;
$$




