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

	BEGIN

		ALTER TABLE public."EmailMessages" DROP CONSTRAINT IF EXISTS "PK_EmailMessages";
		ALTER TABLE public."EmailMessages" ADD CONSTRAINT "PK_EmailMessages" PRIMARY KEY ("Id");
		EXCEPTION
			WHEN OTHERS THEN RAISE NOTICE 'Add PRIMARY KEY to table EmailMessages error.';
		END;
	END;
$$



