ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.ilBadgeDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected ilDBInterface $db;
24
25 public function prepare(ilDBInterface $db): void
26 {
27 $this->db = $db;
28 }
29
30 public function step_1(): void
31 {
32 if (!$this->db->tableColumnExists('badge_badge', 'image_rid')) {
33 $this->db->addTableColumn(
34 'badge_badge',
35 'image_rid',
36 [
37 'type' => 'text',
38 'length' => 64,
39 'notnull' => false,
40 'default' => '',
41 ]
42 );
43 }
44 }
45
46 public function step_2(): void
47 {
48 if (!$this->db->tableColumnExists('badge_image_template', 'image_rid')) {
49 $this->db->addTableColumn(
50 'badge_image_template',
51 'image_rid',
52 [
53 'type' => 'text',
54 'length' => 64,
55 'notnull' => false,
56 'default' => '',
57 ]
58 );
59 }
60 }
61
62 public function step_3(): void
63 {
64 $this->db->manipulate(
65 'UPDATE badge_badge SET image_rid = NULL WHERE image_rid = ' . $this->db->quote(
66 '-',
68 )
69 );
70 $this->db->manipulate(
71 'UPDATE badge_image_template SET image_rid = NULL WHERE image_rid = ' . $this->db->quote(
72 '-',
74 )
75 );
76 if ($this->db->tableColumnExists('badge_badge', 'image')) {
77 $this->db->dropTableColumn('badge_badge', 'image');
78 }
79 if ($this->db->tableColumnExists('badge_image_template', 'image')) {
80 $this->db->dropTableColumn('badge_image_template', 'image');
81 }
82 }
83}
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...