Lae/database/migrations/2023_02_02_195733_create_tasks_table.php

41 lines
1.1 KiB
PHP
Raw Normal View History

2023-02-02 12:11:41 +00:00
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::create('tasks', function (Blueprint $table) {
2023-02-02 12:22:59 +00:00
$table->uuid('id')->primary();
2023-02-02 12:11:41 +00:00
$table->string('title');
$table->unsignedTinyInteger('progress')->nullable();
$table->enum('status', ['pending', 'done', 'success', 'failed', 'error', 'cancelled', 'processing', 'need_operation'])->index();
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('host_id')->index();
$table->string('module_id')->nullable()->index();
$table->timestamps();
});
// 设置存储引擎为 MEMORY
DB::statement('ALTER TABLE tasks ENGINE = MEMORY');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::dropIfExists('tasks');
}
};