       update tjsm T set "releaseName" = T."gitTagName" where "isRelease" = true and "releaseName" is null;
 
       -- update contextTypeCode, contextValue
-      update tjsm set "contextTypeCode" = 302, "contextValue" = tjsm."gitTagName" where "isGitTag" = true;
-      update tjsm set "contextTypeCode" = 303, "contextValue" = tjsm."releaseName" where "isRelease" = true;
-      update tjsm set "contextTypeCode" = 304, "contextValue" = tjsm."pullRequestNumber" where "isPullRequest" = true;
-      update tjsm set "contextTypeCode" = 301, "contextValue" = tjsm.bn where "isPullRequest" = false and "isGitTag" = false and "isRelease" = false;
+      update tjsm set "contextTypeCode" = 302, "contextValue" = tjsm."gitTagName", "contextDetail" = tjsm."commitSha" where "isGitTag" = true;
+      update tjsm set "contextTypeCode" = 303, "contextValue" = tjsm."releaseName", "contextDetail" = tjsm."gitTagName" where "isRelease" = true;
+      update tjsm set "contextTypeCode" = 304, "contextValue" = tjsm."pullRequestNumber", "contextDetail" = tjsm.bn where "isPullRequest" = true;
+      update tjsm set "contextTypeCode" = 301, "contextValue" = tjsm.bn, "contextDetail" = tjsm."commitSha" where "isPullRequest" = false and "isGitTag" = false and "isRelease" = false;
       update tjsm set "updatedBy" = tjsm."createdBy" where "updatedBy" is null;
 
       -- update lastSuccessfulJobId, lastUnstableJobId, lastTimedoutJobId, lastFailedJobId

      update rtjsm set "contextTypeCode" = 312 where "contextTypeCode" = 2014;
      update rtjsm set "contextTypeCode" = 313 where "contextTypeCode" = 2013;

      update tjsm T1 set "contextValue" = T2."contextValue" from rtjsm T2 where T1.rid = T2.id;
      update tjsm T1 set "contextTypeCode" = T2."contextTypeCode" from rtjsm T2 where T1.rid = T2.id;
      update tjsm T1 set "createdBy" = T2."createdBy" from rtjsm T2 where T1.rid = T2.id;
      update tjsm T1 set "updatedBy" = T2."updatedBy" from rtjsm T2 where T1.rid = T2.id;

      -- ignoring records which are not part of (2010,2000,2005,2007,2012,2011,2009) typeCodes
      delete from tjsm where "contextValue" is null;


      create temp table tjsm as WITH cte AS
      (
         SELECT "id", "projectId", "resourceId", "createdAt", "statusCode", "subscriptionId", "updatedAt", ROW_NUMBER() OVER (PARTITION BY "projectId", "resourceId", "statusCode" ORDER BY "createdAt" desc)
      AS rn FROM builds WHERE "statusCode" in (4002,4003)
      )
      SELECT "id", "projectId" as pid, "resourceId" as rid, "createdAt", "statusCode", "subscriptionId", "updatedAt"
      FROM cte
      WHERE rn = 1;

      create temp table rtjsm as WITH cte AS
      (
         SELECT "id", "projectId", "createdAt", "createdBy", "updatedBy", "name", "typeCode", "isJob", "lastVersionName", "lastVersionNumber" FROM resources WHERE "isJob" = true and "typeCode" in (2010,2000,2005,2007,2012,2011,2009)
      )
      SELECT "id", "projectId" as rpid, "createdAt", "createdBy", "updatedBy", "name" as "contextValue", "typeCode" as "contextTypeCode", "lastVersionName" as "contextDetail", "lastVersionNumber"
      FROM cte;

      update rtjsm set "contextDetail" = rtjsm."lastVersionNumber" where "contextDetail" is null;

      -- add required columns to temp table tjsm
      alter table tjsm add column "contextValue" varchar(255), add column "contextTypeCode" int, add column "contextDetail" varchar(255), add column "lastSuccessfulJobId" varchar(24), add column "lastFailedJobId" varchar(24), add column "createdBy" varchar(24), add column "updatedBy" varchar(24);

      -- update contextTypeCode, contextValue
      update rtjsm set "contextTypeCode" = 305 where "contextTypeCode" = 2010;
