
DO $$ 
    BEGIN
         IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
 
        BEGIN
  CREATE TABLE public."Payments" (
	"Id" BIGSERIAL NOT NULL PRIMARY KEY,
	"OrderId" character varying(64) NOT NULL,
	"Amount" FLOAT NOT NULL,
	"UserId" INT NOT NULL, 
	"Type" INT NOT NULL, 
	"Status" INT NOT NULL, 
	"Description" character varying(1024) NULL,
	"Url" character varying(1024) NULL,
	"Timestamp" timestamp without time zone DEFAULT timezone('utc', now())  NOT NULL,
	"Json" character varying(4000) DEFAULT '{}' NULL,
        "ExternalId" character varying(64) NOT NULL,
        "ConfirmationToken" character varying(64) NOT NULL
);



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






