File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments