ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSkillDBUpdateSteps.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->sequenceExists('skl_self_eval')) {
33 $this->db->dropSequence('skl_self_eval');
34 }
35
36 if ($this->db->tableExists('skl_self_eval')) {
37 $this->db->dropTable('skl_self_eval');
38 }
39
40 if ($this->db->tableExists('skl_self_eval_level')) {
41 $this->db->dropTable('skl_self_eval_level');
42 }
43 }
44
45 public function step_2(): void
46 {
47 if (!$this->db->tableColumnExists('skl_user_skill_level', 'trigger_user_id')) {
48 $this->db->addTableColumn(
49 'skl_user_skill_level',
50 'trigger_user_id',
51 array(
52 'type' => 'text',
53 'notnull' => true,
54 'length' => 20,
55 'default' => "-"
56 )
57 );
58 }
59 }
60
61 public function step_3(): void
62 {
63 if (!$this->db->tableColumnExists('skl_user_has_level', 'trigger_user_id')) {
64 $this->db->addTableColumn(
65 'skl_user_has_level',
66 'trigger_user_id',
67 array(
68 'type' => 'text',
69 'notnull' => true,
70 'length' => 20,
71 'default' => "-"
72 )
73 );
74 }
75 }
76
77 public function step_4(): void
78 {
79 // moved to ilSkillSetupAgent using Objectives
80 }
81
82 public function step_5(): void
83 {
84 // moved to ilSkillSetupAgent using Objectives
85 }
86
87 public function step_6(): void
88 {
89 $this->db->update(
90 "object_data",
91 [
92 "title" => ["text", "Default"],
93 "description" => ["text", ""]
94 ],
95 [ // where
96 "type" => ["text", "skee"],
97 "title" => ["text", "Skill Tree"]
98 ]
99 );
100 }
101
102 public function step_7(): void
103 {
104 $set = $this->db->queryF(
105 "SELECT * FROM object_data " .
106 " WHERE type = %s AND title = %s",
107 ["string", "string"],
108 ["skee", "Default"]
109 );
110 $rec = $this->db->fetchAssoc($set);
111
112 $this->db->update(
113 "skl_tree",
114 [
115 "skl_tree_id" => ["integer", $rec["obj_id"]]
116 ],
117 [ // where
118 "skl_tree_id" => ["integer", 1]
119 ]
120 );
121 }
122
123 public function step_8(): void
124 {
125 if (!$this->db->tableColumnExists("skl_profile", "skill_tree_id")) {
126 $this->db->addTableColumn("skl_profile", "skill_tree_id", array(
127 "type" => "integer",
128 "notnull" => true,
129 "default" => 0,
130 "length" => 4
131 ));
132 }
133 }
134
135 public function step_9(): void
136 {
137 $set = $this->db->queryF(
138 "SELECT * FROM object_data " .
139 " WHERE type = %s AND title = %s",
140 ["string", "string"],
141 ["skee", "Default"]
142 );
143 $rec = $this->db->fetchAssoc($set);
144
145 $this->db->update(
146 "skl_profile",
147 [
148 "skill_tree_id" => ["integer", $rec["obj_id"]]
149 ],
150 [ // where
151 "skill_tree_id" => ["integer", 0]
152 ]
153 );
154 }
155
156 public function step_10(): void
157 {
158 if (!$this->db->tableColumnExists("skl_profile", "image_id")) {
159 $this->db->addTableColumn("skl_profile", "image_id", array(
160 "type" => "text",
161 "notnull" => true,
162 "length" => 4000
163 ));
164 }
165 }
166
167 public function step_11(): void
168 {
169 if (!$this->db->tableExists("skl_profile_completion")) {
170 $fields = [
171 "profile_id" => [
172 "type" => "integer",
173 "length" => 4,
174 "notnull" => true
175 ],
176 "user_id" => [
177 "type" => "integer",
178 "length" => 4,
179 "notnull" => true
180 ],
181 "date" => [
182 "type" => "timestamp",
183 "notnull" => true
184 ],
185 "fulfilled" => [
186 "type" => "integer",
187 "length" => 1,
188 "notnull" => true
189 ]
190 ];
191 $this->db->createTable("skl_profile_completion", $fields);
192 $this->db->addPrimaryKey("skl_profile_completion", ["profile_id", "user_id", "date"]);
193 }
194 }
195}
return true
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...