2019_09_15_000020_create_domains_table.php 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. use Illuminate\Database\Migrations\Migration;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Support\Facades\Schema;
  6. class CreateDomainsTable extends Migration
  7. {
  8. /**
  9. * Get the migration connection name.
  10. */
  11. public function getConnection(): ?string
  12. {
  13. return config('tenancy.database.central_connection');
  14. }
  15. /**
  16. * Run the migrations.
  17. *
  18. * @return void
  19. */
  20. public function up(): void
  21. {
  22. Schema::create('domains', function (Blueprint $table) {
  23. $table->increments('id');
  24. $table->string('domain', 255)->unique();
  25. $table->string('tenant_id');
  26. $table->timestamps();
  27. $table->foreign('tenant_id')->references('id')->on('tenants')->onUpdate('cascade')->onDelete('cascade');
  28. });
  29. }
  30. /**
  31. * Reverse the migrations.
  32. *
  33. * @return void
  34. */
  35. public function down(): void
  36. {
  37. Schema::dropIfExists('domains');
  38. }
  39. }