id(); $table->string('name', 255); $table->string('target', 64)->unique(); $table->string('telegram_chat_id', 24)->nullable()->unique(); $table->boolean('enabled'); $table->json('message'); $table->timestamps(); }); } if (!Schema::hasTable('telegram_channel_settings')) { Schema::create('telegram_channel_settings', function (Blueprint $table) { $table->unsignedTinyInteger('id')->primary(); $table->unsignedBigInteger('default_channel_id')->nullable(); }); } DB::transaction(function () { $settings = DB::table('telegram_channel_settings'); if ($settings->where('id', 1)->exists()) { return; } $defaultId = null; $legacy = Schema::hasTable('config') ? DB::table('config')->where('field', 'channel_message')->value('val') : null; $channel = TelegramChannelService::legacyChannel(json_decode($legacy ?? '', true)); if ($channel !== null) { $defaultId = DB::table('telegram_channels')->insertGetId($channel + ['created_at' => now(), 'updated_at' => now()]); } $settings->insert(['id' => 1, 'default_channel_id' => $defaultId]); }); } public function down(): void { Schema::dropIfExists('telegram_channel_settings'); Schema::dropIfExists('telegram_channels'); } };