File modules/cms/update/version/DBVersion000008.class.php
Last commit: Sun Oct 1 02:58:08 2023 +0200 Jan Dankert Refactoring: No it is possible to use 8 byte integers in the database
1 <?php 2 3 namespace cms\update\version; 4 5 use database\DbVersion; 6 use database\Column; 7 use security\Password; 8 9 /** 10 * Creates a type column in table OBJECT. Now added types have no need for new table columns. 11 * 12 * @author dankert 13 * 14 */ 15 class DBVersion000008 extends DbVersion 16 { 17 /** 18 * 19 */ 20 public function update() 21 { 22 $table = $this->table('object'); 23 24 $table->column('typeid')->type(Column::TYPE_INT)->size(Column::SIZE_INT_MED)->defaultValue(0)->add(); 25 $table->addIndex('typeid'); 26 27 // Converting old values... 28 $db = $this->getDb(); 29 $tableName = $table->getSqlName(); 30 31 $updateStmt = $db->sql('UPDATE '.$tableName. 32 ' SET typeid=1 WHERE is_folder=1' 33 ); 34 $updateStmt->execute(); 35 36 $updateStmt = $db->sql('UPDATE '.$tableName. 37 ' SET typeid=2 WHERE is_file=1' 38 ); 39 $updateStmt->execute(); 40 41 $updateStmt = $db->sql('UPDATE '.$tableName. 42 ' SET typeid=3 WHERE is_page=1' 43 ); 44 $updateStmt->execute(); 45 46 $updateStmt = $db->sql('UPDATE '.$tableName. 47 ' SET typeid=4 WHERE is_link=1' 48 ); 49 $updateStmt->execute(); 50 51 $table->column('is_folder')->drop(); 52 $table->column('is_file' )->drop(); 53 $table->column('is_page' )->drop(); 54 $table->column('is_link' )->drop(); 55 } 56 }
Downloadmodules/cms/update/version/DBVersion000008.class.php
History Sun, 1 Oct 2023 02:58:08 +0200 Jan Dankert Refactoring: No it is possible to use 8 byte integers in the database Sun, 7 Mar 2021 00:10:20 +0100 Jan Dankert Refactoring: Hopefully more performance while accessing the database resultsets. Fri, 25 Sep 2020 01:00:58 +0200 Jan Dankert Refactoring: More OO in the database updater :) Sun, 23 Feb 2020 00:30:10 +0100 Jan Dankert Refactoring: Namespacing for module 'database-update', now called 'cms\update'.