ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilResourceStorageDB90.php
Go to the documentation of this file.
1<?php
2
21
27{
28 protected ilDBInterface $db;
29
30 public function prepare(ilDBInterface $db): void
31 {
32 $this->db = $db;
33 }
34
35
40 public function step_1(): void
41 {
42 $flavour_table = "il_resource_flavour";
43 $this->db->dropTable($flavour_table, false);
44 if ($this->db->tableExists($flavour_table)) {
45 return;
46 }
47
48 $this->db->createTable($flavour_table, [
49 'rid' => [
50 'notnull' => true,
51 'length' => '64',
52 'type' => 'text',
53 ],
54 'revision' => [
55 'notnull' => true,
56 'length' => '8',
57 'type' => 'integer',
58 ],
59 'definition_id' => [
60 'notnull' => true,
61 'length' => '64',
62 'type' => 'text',
63 ],
64 'variant' => [
65 'notnull' => false,
66 'length' => '768',
67 'type' => 'text',
68 ]
69 ]);
70
71 $this->db->addIndex($flavour_table, ['rid'], 'i1');
72 $this->db->addIndex($flavour_table, ['definition_id'], 'i3');
73 $this->db->addIndex($flavour_table, ['variant'], 'i4');
74 $this->db->addPrimaryKey($flavour_table, ['rid', 'revision', 'definition_id', 'variant']);
75 }
76
77 public function step_2(): void
78 {
79 // Remove some unused indexes, since they are in primaries now
80 try {
81 $this->db->dropIndexByFields('il_resource_info', ['rid']);
82 } catch (Exception) {
83 }
84 try {
85 $this->db->dropIndexByFields('il_resource_revision', ['rid']);
86 } catch (Exception) {
87 }
88 try {
89 $this->db->dropIndexByFields('il_resource_stkh_u', ['rid']);
90 } catch (Exception) {
91 }
92 }
93
94 public function step_3(): void
95 {
96 // add column rtype to il_resource
97 $this->db->addTableColumn('il_resource', 'rtype', [
98 'type' => 'integer',
99 'length' => '1',
100 'notnull' => true,
101 'default' => ResourceType::SINGLE_FILE->value
102 ]);
103 }
104
105 public function step_4(): void
106 {
107 // add column rtype to il_resource
108 $this->db->addTableColumn('il_resource_revision', 'status', [
109 'type' => 'integer',
110 'length' => '2',
111 'notnull' => true,
112 'default' => RevisionStatus::PUBLISHED->value
113 ]);
114 }
115}
Class ilResourceStorageDB90.
step_1()
creates a new database table "il_resource_flavour" that is used to reference resource flavours to it'...
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...