
DO $$ 
    BEGIN
         IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
 
        BEGIN
 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 NULL,
	"FinishDate" timestamp NULL,
        "IsActive" INT DEFAULT 1 NOT NULL,   
	"Timestamp" timestamp without time zone DEFAULT timezone('utc', now())  NOT NULL
);



        EXCEPTION
            WHEN duplicate_table THEN RAISE NOTICE 'Create table <PaymentsHistory>.';
        END;
    END;
$$







