ILIAS  release_8 Revision v8.23
ilResourceStorageDB80 Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilResourceStorageDB80:
+ Collaboration diagram for ilResourceStorageDB80:

Public Member Functions

 prepare (ilDBInterface $db)
 
 step_1 ()
 
 step_2 ()
 
 step_3 ()
 
 step_4 ()
 
 step_5 ()
 
 step_6 ()
 
 step_7 ()
 
 step_8 ()
 
 step_9 ()
 
 step_10 ()
 
 step_11 ()
 
 step_12 ()
 
 step_13 ()
 
- Public Member Functions inherited from ilDatabaseUpdateSteps
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilResourceStorageDB80

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 23 of file class.ilResourceStorageDB80.php.

Member Function Documentation

◆ prepare()

ilResourceStorageDB80::prepare ( ilDBInterface  $db)

Definition at line 27 of file class.ilResourceStorageDB80.php.

References $db.

27  : void
28  {
29  $this->db = $db;
30  }

◆ step_1()

ilResourceStorageDB80::step_1 ( )

Definition at line 32 of file class.ilResourceStorageDB80.php.

32  : void
33  {
34  if (!$this->db->tableExists('il_resource_stkh_u') && $this->db->tableExists('il_resource_stakeh')) {
35  $this->db->renameTable('il_resource_stakeh', 'il_resource_stkh_u');
36  $this->db->createTable(
37  'il_resource_stkh',
38  [
39  'id' => ['type' => 'text', 'length' => 32, 'notnull' => true, 'default' => ''],
40  'class_name' => ['type' => 'text', 'length' => 250, 'notnull' => true, 'default' => ''],
41  ]
42  );
43  $this->db->addPrimaryKey('il_resource_stkh', ['id']);
44  $this->db->manipulate(
45  "INSERT INTO il_resource_stkh (id, class_name) SELECT DISTINCT stakeholder_id, stakeholder_class FROM il_resource_stkh_u;"
46  );
47  }
48 
49  if ($this->db->tableColumnExists('il_resource_stkh_u', 'stakeholder_class')) {
50  $this->db->dropTableColumn('il_resource_stkh_u', 'stakeholder_class');
51  }
52  if ($this->db->tableColumnExists('il_resource_stkh_u', 'internal')) {
53  $this->db->dropTableColumn('il_resource_stkh_u', 'internal');
54  }
55  }

◆ step_10()

ilResourceStorageDB80::step_10 ( )

Definition at line 302 of file class.ilResourceStorageDB80.php.

302  : void
303  {
304  if (!$this->db->primaryExistsByFields('il_resource_rca', ['rcid', 'rid'])) {
305  $this->db->addPrimaryKey(
306  'il_resource_rca',
307  [
308  'rcid',
309  'rid',
310  ]
311  );
312  }
313 
314  if (!$this->db->primaryExistsByFields('il_resource_rc', ['rcid'])) {
315  $this->db->addPrimaryKey(
316  'il_resource_rc',
317  [
318  'rcid'
319  ]
320  );
321  }
322  }

◆ step_11()

ilResourceStorageDB80::step_11 ( )

Definition at line 324 of file class.ilResourceStorageDB80.php.

324  : void
325  {
326  $this->db->modifyTableColumn(
327  'il_resource_rc',
328  'owner',
329  ['length' => 4]
330  );
331 
332  $this->db->modifyTableColumn(
333  'il_resource_revision',
334  'owner_id',
335  ['length' => 4]
336  );
337  }

◆ step_12()

ilResourceStorageDB80::step_12 ( )

Definition at line 339 of file class.ilResourceStorageDB80.php.

339  : void
340  {
341  $this->db->renameTableColumn(
342  'il_resource_rc',
343  'owner',
344  'owner_id',
345  );
346  }

◆ step_13()

ilResourceStorageDB80::step_13 ( )

Definition at line 348 of file class.ilResourceStorageDB80.php.

348  : void
349  {
350  if ($this->db->indexExistsByFields('il_resource_stkh_u', ['stakeholder_id'])) {
351  $this->db->dropIndexByFields('il_resource_stkh_u', ['stakeholder_id']);
352  }
353  if ($this->db->indexExistsByFields('il_resource_stkh_u', ['rid'])) {
354  $this->db->dropIndexByFields('il_resource_stkh_u', ['rid']);
355  }
356  if (!$this->db->primaryExistsByFields('il_resource_stkh_u', ['rid'])) {
357  $this->db->addPrimaryKey('il_resource_stkh_u', ['rid']);
358  }
359  }

◆ step_2()

ilResourceStorageDB80::step_2 ( )

Definition at line 57 of file class.ilResourceStorageDB80.php.

57  : void
58  {
59  // rename all identification columns to rid
60  if (!$this->db->tableColumnExists('il_resource', 'rid')) {
61  $this->db->renameTableColumn(
62  'il_resource',
63  'identification',
64  'rid'
65  );
66  }
67  if (!$this->db->tableColumnExists('il_resource_info', 'rid')) {
68  $this->db->renameTableColumn(
69  'il_resource_info',
70  'identification',
71  'rid'
72  );
73  }
74  if (!$this->db->tableColumnExists('il_resource_revision', 'rid')) {
75  $this->db->renameTableColumn(
76  'il_resource_revision',
77  'identification',
78  'rid'
79  );
80  }
81  if (!$this->db->tableColumnExists('il_resource_stkh_u', 'rid')) {
82  $this->db->renameTableColumn(
83  'il_resource_stkh_u',
84  'identification',
85  'rid'
86  );
87  }
88  }

◆ step_3()

ilResourceStorageDB80::step_3 ( )

Definition at line 90 of file class.ilResourceStorageDB80.php.

References $attributes.

90  : void
91  {
92  // set all rid columns to the same size
93  $attributes = [
94  'length' => 64,
95  'notnull' => true,
96  'default' => '',
97  ];
98  $this->db->modifyTableColumn(
99  'il_resource',
100  'rid',
102  );
103  $this->db->modifyTableColumn(
104  'il_resource_info',
105  'rid',
107  );
108  $this->db->modifyTableColumn(
109  'il_resource_revision',
110  'rid',
112  );
113  $this->db->modifyTableColumn(
114  'il_resource_stkh_u',
115  'rid',
117  );
118  try {
119  $this->db->modifyTableColumn(
120  'file_data',
121  'rid',
123  );
124  } catch (Throwable $exception) {
125  }
126  }
$attributes
Definition: metadata.php:248

◆ step_4()

ilResourceStorageDB80::step_4 ( )

Definition at line 128 of file class.ilResourceStorageDB80.php.

128  : void
129  {
130  if (!$this->db->tableColumnExists('il_resource_info', 'version_number')) {
131  $this->db->addTableColumn(
132  'il_resource_info',
133  'version_number',
134  [
135  'type' => 'integer',
136  'length' => 8
137  ]
138  );
139 
140  $this->db->manipulate(
141  "UPDATE il_resource_info
142 JOIN il_resource_revision ON il_resource_info.internal = il_resource_revision.internal
143 SET il_resource_info.version_number = il_resource_revision.version_number
144 "
145  );
146  }
147  }

◆ step_5()

ilResourceStorageDB80::step_5 ( )

Definition at line 149 of file class.ilResourceStorageDB80.php.

149  : void
150  {
151  // remove internal columns and add primaries
152  if ($this->db->tableColumnExists('il_resource_revision', 'internal')) {
153  $this->db->dropTableColumn('il_resource_revision', 'internal');
154  $this->db->addPrimaryKey(
155  'il_resource_revision',
156  [
157  'rid',
158  'version_number',
159  ]
160  );
161  }
162  if ($this->db->tableColumnExists('il_resource_info', 'internal')) {
163  $this->db->dropTableColumn('il_resource_info', 'internal');
164  $this->db->addPrimaryKey(
165  'il_resource_info',
166  [
167  'rid',
168  'version_number',
169  ]
170  );
171  }
172  if ($this->db->tableColumnExists('il_resource_stkh', 'internal')) {
173  $this->db->dropTableColumn('il_resource_stkh', 'internal');
174  $this->db->addPrimaryKey(
175  'il_resource_stkh',
176  [
177  'rid',
178  'stakeholder_id',
179  ]
180  );
181  }
182  }

◆ step_6()

ilResourceStorageDB80::step_6 ( )

Definition at line 184 of file class.ilResourceStorageDB80.php.

References $attributes.

184  : void
185  {
186  // set several fields to notnull
187  $attributes = [
188  'notnull' => true,
189  'default' => '',
190  ];
191  $table_fields = [
192  'il_resource' => ['storage_id'],
193  'il_resource_info' => ['title', 'size', 'creation_date'],
194  'il_resource_revision' => ['owner_id', 'title'],
195  ];
196  foreach ($table_fields as $table => $fields) {
197  foreach ($fields as $field) {
198  $this->db->modifyTableColumn(
199  $table,
200  $field,
202  );
203  }
204  }
205  }
$attributes
Definition: metadata.php:248

◆ step_7()

ilResourceStorageDB80::step_7 ( )

Definition at line 207 of file class.ilResourceStorageDB80.php.

207  : void
208  {
209  // add index to file_data rid
210  if (!$this->db->indexExistsByFields('file_data', ['rid'])) {
211  $this->db->addIndex('file_data', ['rid'], 'i1');
212  }
213  }

◆ step_8()

ilResourceStorageDB80::step_8 ( )

Definition at line 215 of file class.ilResourceStorageDB80.php.

215  : void
216  {
217  // several changes to irss tables
218  $this->db->modifyTableColumn(
219  'il_resource_revision',
220  'available',
221  [
222  'default' => 1,
223  ]
224  );
225  $this->db->modifyTableColumn(
226  'il_resource_stkh_u',
227  'stakeholder_id',
228  ['length' => 64]
229  );
230  $this->db->modifyTableColumn(
231  'il_resource_stkh',
232  'id',
233  ['length' => 64]
234  );
235  $this->db->modifyTableColumn(
236  'il_resource_info',
237  'title',
238  ['length' => 255]
239  );
240  $this->db->modifyTableColumn(
241  'il_resource_revision',
242  'title',
243  ['length' => 255]
244  );
245  }

◆ step_9()

ilResourceStorageDB80::step_9 ( )

Definition at line 247 of file class.ilResourceStorageDB80.php.

247  : void
248  {
249  if (!$this->db->tableExists('il_resource_rc')) {
250  $this->db->createTable(
251  'il_resource_rc',
252  [
253  'rcid' => [
254  'type' => 'text',
255  'length' => 64,
256  'notnull' => true,
257  'default' => '',
258  ],
259  'title' => [
260  'type' => 'text',
261  'length' => 4000,
262  'notnull' => false,
263  'default' => '',
264  ],
265  'owner' => [
266  'type' => 'integer',
267  'length' => 8,
268  'notnull' => true,
269  'default' => 0,
270  ],
271  ]
272  );
273  }
274 
275  if (!$this->db->tableExists('il_resource_rca')) {
276  $this->db->createTable(
277  'il_resource_rca',
278  [
279  'rcid' => [
280  'type' => 'text',
281  'length' => 64,
282  'notnull' => true,
283  'default' => '',
284  ],
285  'rid' => [
286  'type' => 'text',
287  'length' => 64,
288  'notnull' => true,
289  'default' => '',
290  ],
291  'position' => [
292  'type' => 'integer',
293  'length' => 8,
294  'notnull' => true,
295  'default' => 0,
296  ],
297  ]
298  );
299  }
300  }

Field Documentation

◆ $db

ilDBInterface ilResourceStorageDB80::$db
protected

Definition at line 25 of file class.ilResourceStorageDB80.php.

Referenced by prepare().


The documentation for this class was generated from the following file: