openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

DBVersion000027.class.php (933B)


      1 <?php
      2 
      3 namespace cms\update\version;
      4 
      5 use database\DbVersion;
      6 use database\Column;
      7 use security\Password;
      8 
      9 /**
     10  * The type of a permission is stored in a new column.
     11  *
     12  * @author dankert
     13  *
     14  */
     15 class DBVersion000027 extends DbVersion
     16 {
     17     /**
     18      *
     19      */
     20     public function update()
     21     {
     22     	$table = $this->table('acl');
     23         $table->column('type'  )->type(Column::TYPE_INT)->size(1)->defaultValue(3)->add();
     24 
     25         // Initial Value: Copy from element.
     26         $tableSqlName = $table->getSqlName();
     27 
     28         $updateStmt = $this->getDb()->sql(<<<SQL
     29 UPDATE $tableSqlName
     30    SET type=3;
     31 SQL
     32         );
     33         $updateStmt->execute();
     34 
     35 		$updateStmt = $this->getDb()->sql(<<<SQL
     36 UPDATE $tableSqlName
     37    SET type=2 where groupid is not null;
     38 SQL
     39 		);
     40 		$updateStmt->execute();
     41 
     42 		$updateStmt = $this->getDb()->sql(<<<SQL
     43 UPDATE $tableSqlName
     44    SET type=1 where userid is not null;
     45 SQL
     46 		);
     47 		$updateStmt->execute();
     48 	}
     49 }
     50