<?php

/**
 * @property Controller $owner
 */
class Site24x7ControllerExtension extends Extension
{
    public function onBeforeInit()
    {
        $isCMS       = (bool) is_subclass_of($this->owner, "LeftAndMain");
        $isAjax      = Director::is_ajax();
        $configTable = SiteConfig::current_site_config()->baseTable();
        $dbSchema    = DB::get_schema();

        $isInstalled = false;
        if ($dbSchema->hasTable($configTable)) {
            $configFileds = $dbSchema->fieldList($configTable);
            $isInstalled  = isset($configFileds["RUMKey"]);
        }

        if ($isInstalled && !$isCMS && !$isAjax && !empty(SiteConfig::current_site_config()->RUMKey)) {
            Requirements::javascriptTemplate(Director::getAbsFile(SS_SITE_24X7_DIR."/assets/javascript/site24x7.template.js"),
                                                                  [
                "RUMKey" => SiteConfig::current_site_config()->RUMKey,
            ]);
        }
    }
}

<?php

/**
 * @property Controller $owner
 */
class Site24x7ControllerExtension extends Extension
{
    public function onBeforeInit()
    {
        $isCMS  = (bool) is_subclass_of($this->owner, "LeftAndMain");
        $isAjax = Director::is_ajax();
        if (!$isCMS && !$isAjax && !empty(SiteConfig::current_site_config()->RUMKey)) {
            Requirements::javascriptTemplate(Director::getAbsFile(SS_SITE_24X7_DIR."/assets/javascript/site24x7.template.js"), [
                "RUMKey" => SiteConfig::current_site_config()->RUMKey,
            ]);
        }
    }
}

--- 
+++ 
@@ -7,10 +7,20 @@
 {
     public function onBeforeInit()
     {
-        $isCMS  = (bool) is_subclass_of($this->owner, "LeftAndMain");
-        $isAjax = Director::is_ajax();
-        if (!$isCMS && !$isAjax && !empty(SiteConfig::current_site_config()->RUMKey)) {
-            Requirements::javascriptTemplate(Director::getAbsFile(SS_SITE_24X7_DIR."/assets/javascript/site24x7.template.js"), [
+        $isCMS       = (bool) is_subclass_of($this->owner, "LeftAndMain");
+        $isAjax      = Director::is_ajax();
+        $configTable = SiteConfig::current_site_config()->baseTable();
+        $dbSchema    = DB::get_schema();
+
+        $isInstalled = false;
+        if ($dbSchema->hasTable($configTable)) {
+            $configFileds = $dbSchema->fieldList($configTable);
+            $isInstalled  = isset($configFileds["RUMKey"]);
+        }
+
+        if ($isInstalled && !$isCMS && !$isAjax && !empty(SiteConfig::current_site_config()->RUMKey)) {
+            Requirements::javascriptTemplate(Director::getAbsFile(SS_SITE_24X7_DIR."/assets/javascript/site24x7.template.js"),
+                                                                  [
                 "RUMKey" => SiteConfig::current_site_config()->RUMKey,
             ]);
         }
Check db has been built before including JS
