2023_02_01_155730_create_new_settings_table.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. // rename old settings table
  15. Schema::table('settings', function (Blueprint $table) {
  16. $table->rename('settings_old');
  17. });
  18. // create new settings table
  19. Schema::create('settings', function (Blueprint $table) {
  20. $table->id();
  21. $table->string('name');
  22. $table->json('payload')->nullable();
  23. $table->string('group')->index();
  24. $table->boolean('locked');
  25. $table->timestamps();
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists('settings');
  36. Schema::table('settings_old', function (Blueprint $table) {
  37. $table->rename("settings");
  38. });
  39. }
  40. };