2022_01_22_152901_create_sentences_table.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateSentencesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. /*
  15. parent_uid VARCHAR (36),
  16. block_uid VARCHAR (36),
  17. channel_uid VARCHAR (36),
  18. book_id INTEGER NOT NULL,
  19. paragraph INTEGER NOT NULL,
  20. word_start INTEGER NOT NULL,
  21. word_end INTEGER NOT NULL,
  22. author TEXT,
  23. editor_uid VARCHAR (36),
  24. content TEXT,
  25. language VARCHAR (16),
  26. version INTEGER NOT NULL DEFAULT (1),
  27. status INTEGER NOT NULL DEFAULT (10),
  28. strlen INTEGER,
  29. */
  30. Schema::create('sentences', function (Blueprint $table) {
  31. #使用雪花id
  32. $table->bigInteger('id')->primary();
  33. $table->string('uid',36)->uniqid()->index();
  34. $table->string('parent_uid',36)->nullable()->uniqid()->index();
  35. $table->string('block_uid',36)->nullable()->uniqid()->index();
  36. $table->string('channel_uid',36)->nullable()->uniqid()->index();
  37. $table->integer('book_id');
  38. $table->integer('paragraph');
  39. $table->integer('word_start');
  40. $table->integer('word_end');
  41. $table->string('author',512)->nullable();
  42. $table->string('editor_uid',36);
  43. $table->text('content')->nullable();
  44. $table->enum('content_type',['markdown','text','html'])->default('markdown');
  45. $table->string('language',16);
  46. $table->integer('version')->default(1);
  47. $table->integer('strlen');
  48. $table->integer('status')->default(10);
  49. $table->bigInteger('create_time')->index();
  50. $table->bigInteger('modify_time')->index();
  51. $table->timestamp('created_at')->useCurrent();
  52. $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate();
  53. $table->timestamp('deleted_at')->nullable();
  54. $table->index(['book_id','paragraph','word_start','word_end']);
  55. $table->index(['book_id','paragraph','word_start','word_end','channel_uid']);
  56. });
  57. }
  58. /**
  59. * Reverse the migrations.
  60. *
  61. * @return void
  62. */
  63. public function down()
  64. {
  65. Schema::dropIfExists('sentences');
  66. }
  67. }