-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathVersion000001Date20210719192031.php
More file actions
118 lines (109 loc) · 5.58 KB
/
Version000001Date20210719192031.php
File metadata and controls
118 lines (109 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
declare(strict_types=1);
namespace OCA\TimeTracker\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version000001Date20210719192031 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('timetracker_project')) {
$table = $schema->getTable('timetracker_project');
if ($table->hasColumn('created_by_user_id')) {
$schema->dropTable('timetracker_project');
$table = $schema->createTable('timetracker_project');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('name', 'string', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('client_id', 'integer', [
'notnull' => false,
'length' => 4,
]);
$table->addColumn('created_by_user_uid', 'string', [
'notnull' => true,
'length' => 128,
]);
$table->addColumn('locked', 'integer', [
'notnull' => false,
'default' => 0,
'length' => 4,
]);
$table->addColumn('archived', 'integer', [
'notnull' => false,
'default' => 0,
'length' => 4,
]);
$table->addColumn('created_at', 'integer', [
'notnull' => true,
'length' => 4,
]);
$table->addColumn('color', 'string', [
'notnull' => true,
'default' => '#ffffff',
'length' => 7,
]);
$table->setPrimaryKey(['id']);
}
}
if ($schema->hasTable('timetracker_timeline_entry')) {
$table = $schema->getTable('timetracker_timeline_entry');
if ($table->hasColumn('user_id')) {
$schema->dropTable('timetracker_timeline_entry');
$table = $schema->createTable('timetracker_timeline_entry');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('timeline_id', 'integer', [
'notnull' => false,
'length' => 4,
]);
$table->addColumn('user_uid', 'text', [
'notnull' => true,
'length' => 128,
]);
$table->addColumn('name', 'text', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('project_name', 'text', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('client_name', 'text', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('time_interval', 'text', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('total_duration', 'text', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('created_at', 'integer', [
'notnull' => true,
'length' => 4,
]);
$table->setPrimaryKey(['id'], 'tt_t_e_id_idx');
}
}
return $schema;
}
}