2026_10_27_120000_create_site_settings.php 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Schema;
  6. return new class extends Migration {
  7. public function up(): void
  8. {
  9. Schema::create('site_settings', function (Blueprint $table) {
  10. $table->unsignedInteger('id')->primary();
  11. $table->json('domains');
  12. $table->timestamps();
  13. });
  14. Schema::create('site_setting_translations', function (Blueprint $table) {
  15. $table->unsignedInteger('site_setting_id');
  16. $table->string('language', 8);
  17. $table->text('content');
  18. $table->primary(['site_setting_id', 'language']);
  19. $table->foreign('site_setting_id')->references('id')->on('site_settings')->onDelete('cascade');
  20. });
  21. DB::table('site_settings')->insert(['id' => 1, 'domains' => '[]', 'created_at' => now(), 'updated_at' => now()]);
  22. }
  23. public function down(): void
  24. {
  25. Schema::dropIfExists('site_setting_translations');
  26. Schema::dropIfExists('site_settings');
  27. }
  28. };