DBVersion000011.class.php (1248B)
1 <?php 2 3 4 namespace cms\update\version; 5 6 use database\DbVersion; 7 use database\Column; 8 9 /** 10 * Project gets new columns. 11 * 12 * @author dankert 13 * 14 */ 15 class DBVersion000011 extends DbVersion 16 { 17 /** 18 * 19 */ 20 public function update() 21 { 22 $table = $this->table('project'); 23 24 $table->column( 'url')->type( Column::TYPE_VARCHAR)->size( 255)->defaultValue( '')->add(); 25 $table->column( 'flags')->type( Column::TYPE_INT)->size( 11)->defaultValue( 0)->add(); 26 27 $db = $this->getDb(); 28 $tableProject = $table->getSqlName(); 29 30 // Update the url 31 $updateStmt = $db->sql(<<<SQL 32 UPDATE $tableProject 33 SET url= CONCAT('//',name) 34 SQL 35 ); 36 $updateStmt->execute(); 37 38 // Update the new flags 39 $updateStmt = $db->sql(<<<SQL 40 UPDATE $tableProject 41 SET flags=flags+1 WHERE cut_index=1 42 SQL 43 ); 44 $updateStmt->execute(); 45 46 $updateStmt = $db->sql(<<<SQL 47 UPDATE $tableProject 48 SET flags=flags+2 WHERE content_negotiation=1 49 SQL 50 ); 51 $updateStmt->execute(); 52 53 // now the information is hold in column 'flags', so we can delete the old columns. 54 $table->column( 'cut_index')->drop(); 55 $table->column('content_negotiation')->drop(); 56 } 57 } 58 59 ?>