2024_01_09_052419_create_parental_controls_table.php 1.4 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. public function up(): void
  11. {
  12. Schema::create('parental_controls', function (Blueprint $table) {
  13. $table->id();
  14. $table->unsignedInteger('parent_id')->index();
  15. $table->unsignedInteger('child_id')->unique()->index()->nullable();
  16. $table->string('email')->unique()->nullable();
  17. $table->string('verify_code')->nullable();
  18. $table->timestamp('email_sent_at')->nullable();
  19. $table->timestamp('email_verified_at')->nullable();
  20. $table->json('permissions')->nullable();
  21. $table->softDeletes();
  22. $table->timestamps();
  23. });
  24. Schema::table('user_roles', function (Blueprint $table) {
  25. $table->dropIndex('user_roles_profile_id_unique');
  26. $table->unsignedBigInteger('profile_id')->unique()->nullable()->index()->change();
  27. });
  28. }
  29. /**
  30. * Reverse the migrations.
  31. */
  32. public function down(): void
  33. {
  34. Schema::dropIfExists('parental_controls');
  35. Schema::table('user_roles', function (Blueprint $table) {
  36. $table->dropIndex('user_roles_profile_id_unique');
  37. $table->unsignedBigInteger('profile_id')->unique()->index()->change();
  38. });
  39. }
  40. };