2024_08_03_225932_node_details.php 920 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. use App\Models\Config;
  3. use Illuminate\Database\Migrations\Migration;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Support\Facades\Schema;
  6. return new class extends Migration
  7. {
  8. private static array $configs = ['node_renewal_notification'];
  9. public function up(): void
  10. {
  11. Schema::table('node', static function (Blueprint $table) {
  12. $table->json('details')->nullable()->comment('节点信息')->after('client_limit');
  13. });
  14. if (Config::exists()) {
  15. foreach (self::$configs as $config) {
  16. Config::insert(['name' => $config]);
  17. }
  18. }
  19. }
  20. public function down(): void
  21. {
  22. Schema::table('node', static function (Blueprint $table) {
  23. $table->dropColumn('details');
  24. });
  25. foreach (self::$configs as $config) {
  26. Config::destroy(['name' => $config]);
  27. }
  28. }
  29. };