ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilGlossaryDBUpdateSteps.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("glossary_term", "short_text")) {
33 $this->db->addTableColumn("glossary_term", "short_text", [
34 "type" => "text",
35 "length" => 4000,
36 "notnull" => false
37 ]);
38 }
39
40 if (!$this->db->tableColumnExists("glossary_term", "short_text_dirty")) {
41 $this->db->addTableColumn("glossary_term", "short_text_dirty", [
42 "type" => "integer",
43 "notnull" => true,
44 "length" => 4,
45 "default" => 0
46 ]);
47 }
48 }
49
50 public function step_2(): void
51 {
52 if (!$this->db->tableColumnExists("glossary_definition", "migration")) {
53 $this->db->addTableColumn("glossary_definition", "migration", [
54 "type" => "integer",
55 "notnull" => true,
56 "length" => 4,
57 "default" => 0
58 ]);
59 }
60 }
61
62 public function step_3(): void
63 {
64 if (!$this->db->tableExists('glo_flashcard_term')) {
65 $fields = [
66 'term_id' => [
67 'type' => 'integer',
68 'length' => 4,
69 'notnull' => true,
70 'default' => 0
71 ],
72 'user_id' => [
73 'type' => 'integer',
74 'length' => 4,
75 'notnull' => true,
76 'default' => 0
77 ],
78 'glo_id' => [
79 'type' => 'integer',
80 'length' => 4,
81 'notnull' => true,
82 'default' => 0
83 ],
84 'last_access' => [
85 'type' => 'timestamp',
86 'notnull' => false
87 ],
88 'box_nr' => [
89 'type' => 'integer',
90 'length' => 4,
91 'notnull' => true,
92 'default' => 0
93 ]
94 ];
95 $this->db->createTable("glo_flashcard_term", $fields);
96 $this->db->addPrimaryKey("glo_flashcard_term", ["term_id", "user_id", "glo_id"]);
97 }
98 }
99
100 public function step_4(): void
101 {
102 if (!$this->db->tableExists('glo_flashcard_box')) {
103 $fields = [
104 'box_nr' => [
105 'type' => 'integer',
106 'length' => 4,
107 'notnull' => true,
108 'default' => 0
109 ],
110 'user_id' => [
111 'type' => 'integer',
112 'length' => 4,
113 'notnull' => true,
114 'default' => 0
115 ],
116 'glo_id' => [
117 'type' => 'integer',
118 'length' => 4,
119 'notnull' => true,
120 'default' => 0
121 ],
122 'last_access' => [
123 'type' => 'timestamp',
124 'notnull' => false
125 ]
126 ];
127 $this->db->createTable("glo_flashcard_box", $fields);
128 $this->db->addPrimaryKey("glo_flashcard_box", ["box_nr", "user_id", "glo_id"]);
129 }
130 }
131
132 public function step_5(): void
133 {
134 if (!$this->db->tableColumnExists("glossary", "flash_active")) {
135 $this->db->addTableColumn("glossary", "flash_active", [
136 "type" => "text",
137 "notnull" => true,
138 "length" => 1,
139 "default" => "n"
140 ]);
141 }
142
143 if (!$this->db->tableColumnExists("glossary", "flash_mode")) {
144 $this->db->addTableColumn("glossary", "flash_mode", [
145 "type" => "text",
146 "notnull" => true,
147 "length" => 10,
148 "default" => "term"
149 ]);
150 }
151 }
152
153 public function step_6(): void
154 {
155 if (!$this->db->tableExists('glossary_collection')) {
156 $fields = [
157 'id' => [
158 'type' => 'integer',
159 'length' => 4,
160 'notnull' => true,
161 'default' => 0
162 ],
163 'glo_id' => [
164 'type' => 'integer',
165 'length' => 4,
166 'notnull' => true,
167 'default' => 0
168 ]
169 ];
170 $this->db->createTable("glossary_collection", $fields);
171 $this->db->addPrimaryKey("glossary_collection", ["id", "glo_id"]);
172 }
173 }
174}
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...