2022-08-13 06:04:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
2023-01-30 16:14:07 +00:00
|
|
|
return new class extends Migration
|
|
|
|
{
|
2022-08-13 06:04:47 +00:00
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-01-14 10:02:27 +00:00
|
|
|
public function up(): void
|
2022-08-13 06:04:47 +00:00
|
|
|
{
|
|
|
|
Schema::create('hosts', function (Blueprint $table) {
|
|
|
|
$table->id();
|
|
|
|
$table->string('name')->index();
|
2022-08-14 13:57:56 +00:00
|
|
|
$table->string('module_id')->index();
|
2022-08-13 10:23:34 +00:00
|
|
|
$table->unsignedBigInteger('user_id')->index();
|
2023-02-02 12:11:41 +00:00
|
|
|
$table->decimal('price', 10)->index();
|
|
|
|
$table->decimal('managed_price', 10)->nullable()->index();
|
2022-08-13 06:04:47 +00:00
|
|
|
$table->json('configuration')->nullable();
|
2023-02-02 12:11:41 +00:00
|
|
|
$table->enum('status', ['running', 'stopped', 'error', 'suspended', 'pending', 'unavailable', 'locked'])->default('pending')->index();
|
|
|
|
$table->tinyInteger('hour_at')->nullable()->index();
|
|
|
|
$table->tinyInteger('minute_at')->nullable()->index();
|
|
|
|
$table->timestamp('suspended_at')->nullable()->index();
|
|
|
|
$table->timestamp('unavailable_at')->nullable()->comment('不可用时间');
|
|
|
|
$table->timestamp('locked_at')->nullable()->comment('锁定时间');
|
2022-08-13 06:04:47 +00:00
|
|
|
$table->softDeletes();
|
|
|
|
$table->timestamps();
|
2023-02-02 12:11:41 +00:00
|
|
|
|
|
|
|
$table->foreign(['module_id'])->references(['id'])->on('modules')->onUpdate('CASCADE')->onDelete('NO ACTION');
|
|
|
|
$table->foreign(['user_id'])->references(['id'])->on('users')->onUpdate('NO ACTION')->onDelete('NO ACTION');
|
2022-08-13 06:04:47 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-01-14 10:02:27 +00:00
|
|
|
public function down(): void
|
2022-08-13 06:04:47 +00:00
|
|
|
{
|
|
|
|
Schema::dropIfExists('hosts');
|
|
|
|
}
|
|
|
|
};
|