openrat-cms

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

DBVersion000005.class.php (650B)


      1 <?php
      2 
      3 namespace cms\update\version;
      4 
      5 use database\DbVersion;
      6 use database\Column;
      7 
      8 /**
      9  * Security enhancements.
     10  * 
     11  * @author dankert
     12  *
     13  */
     14 class DBVersion000005 extends DbVersion
     15 {
     16 	public function update()
     17 	{
     18 		$table = $this->table('user');
     19 
     20 		// longer Passwords! 50 is not enough.
     21 		$table->column('password_hash')->type(Column::TYPE_VARCHAR)->size(255)->add();
     22 		
     23 		$db    = $this->getDb();
     24 		$updateStmt = $db->sql('UPDATE '.$table->getSqlName().
     25 				' SET password_hash=password'
     26 		);
     27 		$updateStmt->execute();
     28 
     29 		$table->column('password')->drop();
     30 		
     31 		$table->column('password_salt')->type(Column::TYPE_VARCHAR)->size(255)->add();
     32 	}
     33 }