applications/vanilla/models/class.categorymodel.php
public function ApplyUpdates() {
      if (!C('Vanilla.NestedCategoriesUpdate')) {
         // Add new columns
         $Construct = Gdn::Database()->Structure();
         $Construct->Table('Category')
            ->Column('TreeLeft', 'int', TRUE)
            ->Column('TreeRight', 'int', TRUE)
            ->Column('Depth', 'int', TRUE)
            ->Column('CountComments', 'int', '0')
            ->Column('LastCommentID', 'int', TRUE)
            ->Set(0, 0);

         // Insert the root node
         if ($this->SQL->GetWhere('Category', array('CategoryID' => -1))->NumRows() == 0)
            $this->SQL->Insert('Category', array('CategoryID' => -1, 'TreeLeft' => 1, 'TreeRight' => 4, 'Depth' => 0, 'InsertUserID' => 1, 'UpdateUserID' => 1, 'DateInserted' => Gdn_Format::ToDateTime(), 'DateUpdated' => Gdn_Format::ToDateTime(), 'Name' => 'Root', 'UrlCode' => '', 'Description' => 'Root of category tree. Users should never see this.'));
         
         // Build up the TreeLeft & TreeRight values.
         $this->RebuildTree();
         
         SaveToConfig('Vanilla.NestedCategoriesUpdate', 1);
      }
   }
public function ApplyUpdates() {
      if (!C('Vanilla.NestedCategoriesUpdate')) {
         // Add new columns
         $Construct = Gdn::Database()->Structure();
         $Construct->Table('Category')
            ->Column('TreeLeft', 'int', TRUE)
            ->Column('TreeRight', 'int', TRUE)
            ->Column('Depth', 'int', TRUE)
            ->Column('CountComments', 'int', '0')
            ->Column('LastCommentID', 'int', TRUE)
            ->Set(0, 0);

         // Insert the root node
         if ($this->SQL->GetWhere('Category', array('CategoryID' => -1))->NumRows() == 0)
            $this->SQL->Insert('Category', array('CategoryID' => -1, 'TreeLeft' => 1, 'TreeRight' => 4, 'Depth' => 0, 'InsertUserID' => 1, 'UpdateUserID' => 1, 'DateInserted' => Gdn_Format::ToDateTime(), 'DateUpdated' => Gdn_Format::ToDateTime(), 'Name' => 'Root', 'UrlCode' => '', 'Description' => 'Root of category tree. Users should never see this.'));
         
         // Build up the TreeLeft & TreeRight values.
         $this->RebuildTree();
         
         SaveToConfig('Vanilla.NestedCategoriesUpdate', 1);
      }
   }
public function ApplyUpdates ( ) { if ( ! C ( 'Vanilla.NestedCategoriesUpdate' ) ) { // Add new columns $ Construct = Gdn :: Database ( ) -> Structure ( ) ; $ Construct -> Table ( 'Category' ) -> Column ( 'TreeLeft' , 'int' , TRUE ) -> Column ( 'TreeRight' , 'int' , TRUE ) -> Column ( 'Depth' , 'int' , TRUE ) -> Column ( 'CountComments' , 'int' , '0' ) -> Column ( 'LastCommentID' , 'int' , TRUE ) -> Set ( 0 , 0 ) ; // Insert the root node if ( $ this -> SQL -> GetWhere ( 'Category' , array ( 'CategoryID' => - 1 ) ) -> NumRows ( ) == 0 ) $ this -> SQL -> Insert ( 'Category' , array ( 'CategoryID' => - 1 , 'TreeLeft' => 1 , 'TreeRight' => 4 , 'Depth' => 0 , 'InsertUserID' => 1 , 'UpdateUserID' => 1 , 'DateInserted' => Gdn_Format :: ToDateTime ( ) , 'DateUpdated' => Gdn_Format :: ToDateTime ( ) , 'Name' => 'Root' , 'UrlCode' => '' , 'Description' => 'Root of category tree. Users should never see this.' ) ) ; // Build up the TreeLeft & TreeRight values. $ this -> RebuildTree ( ) ; SaveToConfig ( 'Vanilla.NestedCategoriesUpdate' , 1 ) ; } }
If looking at the root node, make sure it exists and that the
nested set columns exist in the table.

@since 2.0.15
@access public
If looking at the root node make sure it exists and that the nested set columns exist in the table .