Skip to content

Commit 409094d

Browse files
authored
Merge branch 'main' into issue-1407
2 parents a3c0338 + e854592 commit 409094d

File tree

4 files changed

+102
-15
lines changed

4 files changed

+102
-15
lines changed

migrations/065_convert_virtual_playlists.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ public function up()
2020

2121
// fix oc_seminar_series table
2222
$db->exec('SET foreign_key_checks = 0');
23+
if ($db->fetchOne("SELECT 1 FROM information_schema.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = DATABASE() AND TABLE_NAME = 'oc_seminar_series' AND CONSTRAINT_NAME = 'oc_seminar_series_ibfk_1'")) {
24+
$db->exec('ALTER TABLE `oc_seminar_series` DROP FOREIGN KEY `oc_seminar_series_ibfk_1`');
25+
}
2326
$db->exec('ALTER TABLE `oc_seminar_series`
24-
DROP FOREIGN KEY `oc_seminar_series_ibfk_1`,
2527
ADD FOREIGN KEY oc_seminar_series_ibfk_2 (`config_id`) REFERENCES `oc_config` (`id`) ON DELETE CASCADE ON UPDATE CASCADE');
2628
$db->exec('SET foreign_key_checks = 1');
2729

2830
// add switch to playlist-course relation to denote if this is the default playlist for this course
2931
$db->exec('ALTER TABLE oc_playlist_seminar
3032
ADD `is_default` tinyint DEFAULT 0 AFTER seminar_id');
3133

32-
SimpleOrMap::expireTableScheme();
33-
3434
$result = $db->query("SELECT * FROM oc_video_seminar");
3535

3636
// collect videos for playlists
@@ -82,14 +82,10 @@ public function up()
8282

8383
// remove obsolete table
8484
$db->exec('DROP TABLE `oc_video_seminar`');
85-
86-
SimpleOrMap::expireTableScheme();
8785
}
8886

8987
public function down()
9088
{
9189
$db = DBManager::get();
92-
93-
SimpleOrMap::expireTableScheme();
9490
}
9591
}

migrations/070_drop_obsolete_config_fields.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,40 @@ public function up()
1111
{
1212
$db = DBManager::get();
1313

14-
$db->exec("ALTER TABLE `oc_config`
15-
DROP FOREIGN KEY `oc_config_ibfk_1`,
16-
DROP FOREIGN KEY `oc_config_ibfk_2`
14+
$stmt = $db->prepare("
15+
SELECT CONSTRAINT_NAME
16+
FROM information_schema.TABLE_CONSTRAINTS
17+
WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'
18+
AND TABLE_SCHEMA = DATABASE()
19+
AND TABLE_NAME = 'oc_config'
1720
");
21+
$stmt->execute();
22+
$foreign_keys = $stmt->fetchAll(PDO::FETCH_COLUMN);
23+
24+
foreach ($foreign_keys as $fk_name) {
25+
$db->exec("ALTER TABLE `oc_config` DROP FOREIGN KEY `{$fk_name}`");
26+
}
1827

1928
$db->exec("ALTER TABLE `oc_config`
2029
DROP `upload`,
2130
DROP `schedule`
2231
");
23-
24-
SimpleOrMap::expireTableScheme();
2532
}
2633

2734
public function down()
2835
{
36+
$db = DBManager::get();
2937

38+
$db->exec("ALTER TABLE `oc_config`
39+
ADD COLUMN `upload` int(11) DEFAULT NULL,
40+
ADD COLUMN `schedule` int(11) DEFAULT NULL
41+
");
42+
43+
$db->exec("ALTER TABLE `oc_config`
44+
ADD KEY `upload` (`upload`),
45+
ADD KEY `schedule` (`schedule`),
46+
ADD CONSTRAINT `oc_config_ibfk_1` FOREIGN KEY (`upload`) REFERENCES `oc_workflow_config` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
47+
ADD CONSTRAINT `oc_config_ibfk_2` FOREIGN KEY (`schedule`) REFERENCES `oc_workflow_config` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
48+
");
3049
}
3150
}

migrations/077_update_cw_block.php

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ public function up()
3737
");
3838
}
3939

40-
$db->exec('ALTER TABLE oc_video_cw_blocks
41-
DROP FOREIGN KEY `oc_video_cw_blocks_ibfk_1`
42-
');
40+
$fk_name = $db->fetchColumn("SELECT CONSTRAINT_NAME
41+
FROM information_schema.KEY_COLUMN_USAGE
42+
WHERE TABLE_SCHEMA = DATABASE()
43+
AND TABLE_NAME = 'oc_video_cw_blocks'
44+
AND COLUMN_NAME = 'video_id'
45+
AND REFERENCED_TABLE_NAME = 'oc_video'
46+
");
47+
48+
if ($fk_name) {
49+
$db->exec("ALTER TABLE oc_video_cw_blocks DROP FOREIGN KEY `{$fk_name}`");
50+
}
4351

4452
$db->exec('ALTER TABLE oc_video_cw_blocks
4553
ADD PRIMARY KEY `token_block_id` (`token`, `block_id`),
@@ -59,6 +67,55 @@ public function up()
5967

6068
public function down()
6169
{
70+
$db = DBManager::get();
71+
$db->exec('START TRANSACTION');
72+
73+
$db->exec('ALTER TABLE oc_video_cw_blocks
74+
ADD `video_id` char(32) CHARACTER SET latin1 COLLATE latin1_bin AFTER `token`');
75+
76+
$results = $db->query("SELECT DISTINCT oc_video_cw_blocks.token, oc_video.id
77+
FROM oc_video_cw_blocks
78+
LEFT JOIN oc_video ON (oc_video.token = oc_video_cw_blocks.token)
79+
");
80+
$entries = $results->fetchAll(PDO::FETCH_ASSOC);
81+
82+
$stmt = $db->prepare('UPDATE oc_video_cw_blocks
83+
SET video_id = :video_id
84+
WHERE token = :token
85+
');
6286

87+
foreach ($entries as $data) {
88+
// update mapping table
89+
$stmt->execute([
90+
':video_id' => $data['id'],
91+
':token' => $data['token']
92+
]);
93+
94+
// update block payloads
95+
$db->exec("UPDATE cw_blocks
96+
SET payload = REPLACE(payload, '\"token\":\"". $data['token'] ."\"', '\"video_id\":\"". $data['id'] ."\"')
97+
WHERE payload LIKE '%\"token\":\"". $data['token'] ."\"%'
98+
AND block_type = 'plugin-opencast-video'
99+
");
100+
}
101+
102+
$db->exec('ALTER TABLE oc_video_cw_blocks
103+
DROP FOREIGN KEY `token`
104+
');
105+
106+
$db->exec('ALTER TABLE oc_video_cw_blocks
107+
ADD PRIMARY KEY `block_id` (`block_id`),
108+
DROP INDEX `token_block_id`
109+
');
110+
111+
$db->exec('ALTER TABLE oc_video_cw_blocks
112+
ADD FOREIGN KEY (`video_id`) REFERENCES `oc_video` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
113+
');
114+
115+
$db->exec('ALTER TABLE oc_video_cw_blocks
116+
DROP token
117+
');
118+
119+
$db->exec('COMMIT');
63120
}
64121
}

vueapp/components/Config/EditServer.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ export default {
198198
type: 'boolean',
199199
required: false
200200
},
201+
description: this.$gettext('Timeout (in Millisekunden)'),
202+
name: 'timeout_ms',
203+
value: this.currentConfig.timeout_ms ?? '0',
204+
type: 'integer',
205+
placeholder: '0',
206+
required: true
207+
},
208+
{
209+
description: this.$gettext('Verbindungs-Timeout (in Millisekunden)'),
210+
name: 'connect_timeout_ms',
211+
value: this.currentConfig.connect_timeout_ms ?? '2000',
212+
type: 'integer',
213+
placeholder: '2000',
214+
required: true
215+
}
201216
];
202217
},
203218

0 commit comments

Comments
 (0)