Skip to content

Commit 1395625

Browse files
committed
Add migration to fix webhook settings
1 parent d6b69c8 commit 1395625

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
return new class extends Migration {
7+
/**
8+
* Run the migrations.
9+
*/
10+
public function up(): void
11+
{
12+
$settings = DB::table('settings')->first();
13+
14+
/** If webhook settings were cleared via the integration settings page,
15+
* the webhook_selected was cleared as well when it should have reset to "slack".
16+
*/
17+
if (
18+
empty($settings->webhook_selected) &&
19+
(empty($settings->webhook_botname) && empty($settings->webhook_channel) && empty($settings->webhook_endpoint))
20+
) {
21+
DB::table('settings')->update(['webhook_selected' => 'slack']);
22+
}
23+
24+
/** If webhook settings were cleared via the integration settings page,
25+
* then slack settings were re-added; then webhook_selected was not being set to "slack" as needed.
26+
*/
27+
if (str_contains($settings->webhook_endpoint, 'slack.com')) {
28+
DB::table('settings')->update(['webhook_selected' => 'slack']);
29+
}
30+
}
31+
32+
/**
33+
* Reverse the migrations.
34+
*/
35+
public function down(): void
36+
{
37+
//
38+
}
39+
};

0 commit comments

Comments
 (0)