2018_08_08_100000_create_telescope_entries_table.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. * Get the migration connection name.
  9. */
  10. public function getConnection(): ?string
  11. {
  12. return config('telescope.storage.database.connection');
  13. }
  14. /**
  15. * Run the migrations.
  16. */
  17. public function up(): void
  18. {
  19. $schema = Schema::connection($this->getConnection());
  20. $schema->create('telescope_entries', function (Blueprint $table) {
  21. $table->bigIncrements('sequence');
  22. $table->uuid('uuid');
  23. $table->uuid('batch_id');
  24. $table->string('family_hash')->nullable();
  25. $table->boolean('should_display_on_index')->default(true);
  26. $table->string('type', 20);
  27. $table->longText('content');
  28. $table->dateTime('created_at')->nullable();
  29. $table->unique('uuid');
  30. $table->index('batch_id');
  31. $table->index('family_hash');
  32. $table->index('created_at');
  33. $table->index(['type', 'should_display_on_index']);
  34. });
  35. $schema->create('telescope_entries_tags', function (Blueprint $table) {
  36. $table->uuid('entry_uuid');
  37. $table->string('tag');
  38. $table->primary(['entry_uuid', 'tag']);
  39. $table->index('tag');
  40. $table->foreign('entry_uuid')
  41. ->references('uuid')
  42. ->on('telescope_entries')
  43. ->onDelete('cascade');
  44. });
  45. $schema->create('telescope_monitoring', function (Blueprint $table) {
  46. $table->string('tag')->primary();
  47. });
  48. }
  49. /**
  50. * Reverse the migrations.
  51. */
  52. public function down(): void
  53. {
  54. $schema = Schema::connection($this->getConnection());
  55. $schema->dropIfExists('telescope_entries_tags');
  56. $schema->dropIfExists('telescope_entries');
  57. $schema->dropIfExists('telescope_monitoring');
  58. }
  59. };