ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilGlossaryDBUpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
23 {
24  protected \ilDBInterface $db;
25 
26  public function prepare(\ilDBInterface $db): void
27  {
28  $this->db = $db;
29  }
30 
31  public function step_1(): void
32  {
33  if (!$this->db->tableColumnExists("glossary_term", "short_text")) {
34  $this->db->addTableColumn("glossary_term", "short_text", [
35  "type" => "text",
36  "length" => 4000,
37  "notnull" => false
38  ]);
39  }
40 
41  if (!$this->db->tableColumnExists("glossary_term", "short_text_dirty")) {
42  $this->db->addTableColumn("glossary_term", "short_text_dirty", [
43  "type" => "integer",
44  "notnull" => true,
45  "length" => 4,
46  "default" => 0
47  ]);
48  }
49  }
50 
51  public function step_2(): void
52  {
53  if (!$this->db->tableColumnExists("glossary_definition", "migration")) {
54  $this->db->addTableColumn("glossary_definition", "migration", [
55  "type" => "integer",
56  "notnull" => true,
57  "length" => 4,
58  "default" => 0
59  ]);
60  }
61  }
62 
63  public function step_3(): void
64  {
65  if (!$this->db->tableExists('glo_flashcard_term')) {
66  $fields = [
67  'term_id' => [
68  'type' => 'integer',
69  'length' => 4,
70  'notnull' => true,
71  'default' => 0
72  ],
73  'user_id' => [
74  'type' => 'integer',
75  'length' => 4,
76  'notnull' => true,
77  'default' => 0
78  ],
79  'glo_id' => [
80  'type' => 'integer',
81  'length' => 4,
82  'notnull' => true,
83  'default' => 0
84  ],
85  'last_access' => [
86  'type' => 'timestamp',
87  'notnull' => false
88  ],
89  'box_nr' => [
90  'type' => 'integer',
91  'length' => 4,
92  'notnull' => true,
93  'default' => 0
94  ]
95  ];
96  $this->db->createTable("glo_flashcard_term", $fields);
97  $this->db->addPrimaryKey("glo_flashcard_term", ["term_id", "user_id", "glo_id"]);
98  }
99  }
100 
101  public function step_4(): void
102  {
103  if (!$this->db->tableExists('glo_flashcard_box')) {
104  $fields = [
105  'box_nr' => [
106  'type' => 'integer',
107  'length' => 4,
108  'notnull' => true,
109  'default' => 0
110  ],
111  'user_id' => [
112  'type' => 'integer',
113  'length' => 4,
114  'notnull' => true,
115  'default' => 0
116  ],
117  'glo_id' => [
118  'type' => 'integer',
119  'length' => 4,
120  'notnull' => true,
121  'default' => 0
122  ],
123  'last_access' => [
124  'type' => 'timestamp',
125  'notnull' => false
126  ]
127  ];
128  $this->db->createTable("glo_flashcard_box", $fields);
129  $this->db->addPrimaryKey("glo_flashcard_box", ["box_nr", "user_id", "glo_id"]);
130  }
131  }
132 
133  public function step_5(): void
134  {
135  if (!$this->db->tableColumnExists("glossary", "flash_active")) {
136  $this->db->addTableColumn("glossary", "flash_active", [
137  "type" => "text",
138  "notnull" => true,
139  "length" => 1,
140  "default" => "n"
141  ]);
142  }
143 
144  if (!$this->db->tableColumnExists("glossary", "flash_mode")) {
145  $this->db->addTableColumn("glossary", "flash_mode", [
146  "type" => "text",
147  "notnull" => true,
148  "length" => 10,
149  "default" => "term"
150  ]);
151  }
152  }
153 
154  public function step_6(): void
155  {
156  if (!$this->db->tableExists('glossary_collection')) {
157  $fields = [
158  'id' => [
159  'type' => 'integer',
160  'length' => 4,
161  'notnull' => true,
162  'default' => 0
163  ],
164  'glo_id' => [
165  'type' => 'integer',
166  'length' => 4,
167  'notnull' => true,
168  'default' => 0
169  ]
170  ];
171  $this->db->createTable("glossary_collection", $fields);
172  $this->db->addPrimaryKey("glossary_collection", ["id", "glo_id"]);
173  }
174  }
175 }
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...