File modules/cms/update/version/DBVersion000011.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 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)->defaultValue( '')->add(); 25 $table->column( 'flags')->type( Column::TYPE_INT)->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 ?>
Download modules/cms/update/version/DBVersion000011.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'.