ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilEmployeeTalkDBUpdateSteps.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 {
28  protected \ilDBInterface $db;
29 
30  public function prepare(\ilDBInterface $db): void
31  {
32  $this->db = $db;
33  }
34 
35  private function useTransaction(callable $updateStep): void
36  {
37  try {
38  if ($this->db->supportsTransactions()) {
39  $this->db->beginTransaction();
40  }
41  $updateStep($this->db);
42 
43  if ($this->db->supportsTransactions()) {
44  $this->db->commit();
45  }
46  } catch (\Exception $exception) {
47  if ($this->db->supportsTransactions()) {
48  $this->db->rollback();
49  }
50  throw $exception;
51  }
52  }
53 
54  public function step_1(): void
55  {
56  // removed this content in favour of a ilTreeAdminNodeAddedObjective
57  }
58 
59  public function step_2(): void
60  {
61  $this->useTransaction(function (\ilDBInterface $db) {
62  $etalTableName = 'etal_data';
63 
64  if (!$db->tableExists($etalTableName)) {
65  $db->createTable($etalTableName, [
66  'object_id' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
67  'series_id' => ['type' => 'text', 'length' => 36, 'notnull' => true, 'fixed' => true],
68  'start_date' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
69  'end_date' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
70  'all_day' => ['type' => 'integer', 'length' => 1, 'notnull' => true],
71  'employee' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
72  'location' => ['type' => 'text', 'length' => 200, 'notnull' => false, 'fixed' => false],
73  'completed' => ['type' => 'integer', 'length' => 1, 'notnull' => true]
74  ]);
75 
76  $db->addPrimaryKey($etalTableName, ['object_id']);
77  $db->addIndex($etalTableName, ['series_id'], 'ser');
78  $db->addIndex($etalTableName, ['employee'], 'emp');
79  }
80  });
81  }
82 
83  public function step_3(): void
84  {
85  $this->useTransaction(function (\ilDBInterface $db) {
86  $etalTableName = 'etal_data';
87 
88  if (!$db->tableColumnExists($etalTableName, 'standalone_date')) {
89  $db->addTableColumn(
90  $etalTableName,
91  'standalone_date',
92  [
93  'type' => 'integer',
94  'length' => 1,
95  'notnull' => true,
96  'default' => 0
97  ]
98  );
99  }
100  });
101  }
102 
103  public function step_4(): void
104  {
105  // replaced by OrgUnit objectives
106  }
107 
108  public function step_5(): void
109  {
110  $this->useTransaction(function (\ilDBInterface $db) {
111  $table_name = 'etal_serie';
112 
113  if (!$db->tableExists($table_name)) {
114  $db->createTable($table_name, [
115  'id' => ['type' => 'integer', 'length' => 8, 'notnull' => true],
116  'editing_locked' => ['type' => 'integer', 'length' => 1, 'notnull' => true],
117  ]);
118 
119  $db->addPrimaryKey($table_name, ['id']);
120  }
121  });
122  }
123 
124  public function step_6(): void
125  {
126  $this->useTransaction(function (\ilDBInterface $db) {
127  $table_name = 'etal_data';
128  $column_name = 'template_id';
129 
130  if (!$db->tableColumnExists($table_name, $column_name)) {
131  $db->addTableColumn(
132  $table_name,
133  $column_name,
134  [
135  'type' => 'integer',
136  'length' => 8,
137  'notnull' => true,
138  'default' => 0
139  ]
140  );
141  }
142  });
143  }
144 }
tableExists(string $table_name)
addIndex(string $table_name, array $fields, string $index_name='', bool $fulltext=false)
addPrimaryKey(string $table_name, array $primary_keys)
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...
addTableColumn(string $table_name, string $column_name, array $attributes)
prepare(\ilDBInterface $db)
Prepare the execution of the steps.
createTable(string $table_name, array $fields, bool $drop_table=false, bool $ignore_erros=false)