
DO $$ 
    BEGIN
         IF EXISTS (SELECT "Id" FROM public."Versions" WHERE "Build">=1765) THEN
		RETURN;
          END IF;
 
        BEGIN
      CREATE TABLE public."ShortLinks" (
    "Id" bigserial NOT NULL,
    "Uid" character varying(64) NOT NULL,
    "Url" character varying(4000) NOT NULL,
    "EntityId" bigint NOT NULL,
    "EntityType" integer NOT NULL, 
    "UserId" bigint NOT NULL, 
    "Timestamp" timestamp without time zone DEFAULT timezone('utc', now())  NOT NULL, 
     CONSTRAINT "PK_ShortLinks" PRIMARY KEY ("Uid")
); 



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



