Skip to content

Commit bdbb3c3

Browse files
authored
Merge pull request #2294 from opensource-workshop/fix-issues-2293
[Configsデータ] 新規インストール時にエラーが発生する問題を修正しました
2 parents 2c6de5e + 3c71e90 commit bdbb3c3

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Support\Facades\DB;
5+
6+
/**
7+
* マイグレーションでConfigsレコードを作成するのを廃止
8+
*
9+
* 背景:
10+
* - 2025_10_09_160056_add_mail_oauth2_to_configs.php でmail_auth_methodをinsertしていた
11+
* - 新規インストール時、migrate実行後にConfigsテーブルにレコードが1件存在する状態になる
12+
* - DefaultConfigsTableSeeder の条件 if (Configs::count() == 0) が false になる
13+
* - 基本設定レコード(base_site_name等)が投入されず、エラーが発生する
14+
*
15+
* 対応:
16+
* - mail_auth_methodレコードを削除
17+
* - 以降はデフォルト値(MailAuthMethod::smtp)で動作
18+
* - 管理画面で認証方式変更時に自動作成される(updateOrCreate使用)
19+
*
20+
* 関連Issue:
21+
* - https://github.com/opensource-workshop/connect-cms/issues/2293
22+
*/
23+
class RemoveMailAuthMethodFromMigration extends Migration
24+
{
25+
/**
26+
* Run the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function up()
31+
{
32+
// マイグレーションで作成したmail_auth_methodレコードを削除
33+
DB::table('configs')
34+
->where('category', 'mail')
35+
->where('name', 'mail_auth_method')
36+
->delete();
37+
}
38+
39+
/**
40+
* Reverse the migrations.
41+
*
42+
* @return void
43+
*/
44+
public function down()
45+
{
46+
// rollback時は元に戻す
47+
DB::table('configs')->insert([
48+
'category' => 'mail',
49+
'name' => 'mail_auth_method',
50+
'value' => 'smtp',
51+
'created_at' => now(),
52+
'updated_at' => now(),
53+
]);
54+
}
55+
}

0 commit comments

Comments
 (0)