ILIAS  release_8 Revision v8.24
class.ilEmployeeTalkDBUpdateSteps.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
28
33{
34 protected \ilDBInterface $db;
35
36 public function prepare(\ilDBInterface $db): void
37 {
38 $this->db = $db;
39 }
40
41 private function useTransaction(callable $updateStep): void
42 {
43 try {
44 if ($this->db->supportsTransactions()) {
45 $this->db->beginTransaction();
46 }
47 $updateStep($this->db);
48
49 if ($this->db->supportsTransactions()) {
50 $this->db->commit();
51 }
52 } catch (\Exception $exception) {
53 if ($this->db->supportsTransactions()) {
54 $this->db->rollback();
55 }
56 throw $exception;
57 }
58 }
59
60 public function step_1(): void
61 {
62 // removed this content in favour of a ilTreeAdminNodeAddedObjective
63 }
64
65 public function step_2(): void
66 {
67 $this->useTransaction(function (\ilDBInterface $db) {
68 $etalTableName = 'etal_data';
69
70 if (!$db->tableExists($etalTableName)) {
71 $db->createTable($etalTableName, [
72 'object_id' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
73 'series_id' => ['type' => 'text', 'length' => 36, 'notnull' => true, 'fixed' => true],
74 'start_date' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
75 'end_date' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
76 'all_day' => ['type' => 'integer', 'length' => 1, 'notnull' => true],
77 'employee' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
78 'location' => ['type' => 'text', 'length' => 200, 'notnull' => false, 'fixed' => false],
79 'completed' => ['type' => 'integer', 'length' => 1, 'notnull' => true]
80 ]);
81
82 $db->addPrimaryKey($etalTableName, ['object_id']);
83 $db->addIndex($etalTableName, ['series_id'], 'ser');
84 $db->addIndex($etalTableName, ['employee'], 'emp');
85 }
86 });
87 }
88
89 public function step_3(): void
90 {
91 $this->useTransaction(function (\ilDBInterface $db) {
92 $etalTableName = 'etal_data';
93
94 if (!$db->tableColumnExists($etalTableName, 'standalone_date')) {
95 $db->addTableColumn(
96 $etalTableName,
97 'standalone_date',
98 [
99 'type' => 'integer',
100 'length' => 1,
101 'notnull' => true,
102 'default' => 0
103 ]
104 );
105 }
106 });
107 }
108
109 public function step_4(): void
110 {
111 // replaced by OrgUnit objectives
112 }
113
114 public function step_5(): void
115 {
116 $this->useTransaction(function (\ilDBInterface $db) {
117 $table_name = 'etal_serie';
118
119 if (!$db->tableExists($table_name)) {
120 $db->createTable($table_name, [
121 'id' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
122 'editing_locked' => ['type' => 'integer', 'length' => 1, 'notnull' => true],
123 ]);
124
125 $db->addPrimaryKey($table_name, ['id']);
126 }
127 });
128 }
129
130 public function step_6(): void
131 {
132 $this->useTransaction(function (\ilDBInterface $db) {
133 $table_name = 'etal_data';
134 $column_name = 'template_id';
135
136 if (!$db->tableColumnExists($table_name, $column_name)) {
137 $db->addTableColumn(
138 $table_name,
139 $column_name,
140 [
141 'type' => 'integer',
142 'length' => 8,
143 'notnull' => true,
144 'default' => 0
145 ]
146 );
147 }
148 });
149 }
150}
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilDBInterface.
tableExists(string $table_name)
tableColumnExists(string $table_name, string $column_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...